ofxLibwebsockets icon indicating copy to clipboard operation
ofxLibwebsockets copied to clipboard

connection closed event

Open wasawi opened this issue 10 years ago • 3 comments

Hi,

I'm running tests using the example_server_binary_video with videos of many different formats. I usually loose the connection with the client. I would like to know how to start looking for solutions/debugging. I'm quite new at websockets programing so sorry for my very naive questions.

Is it possible to automatically reconnect after a close event? Is the close event due to a lack of time in the javascript side to process the event? if so could that be solved? Has anybody done some tests with heavy videos or high framerates?

I will be looking at this addon for a while so any hints will be very appreciated!

Best, J

BTW is it better to discuss this at the of forum?

My specs: Visual Studio 2015 (Win 7 Pro) Firefox 43.0.4 libwebsockets-1.3-chrome37-firefox30

wasawi avatar Feb 03 '16 09:02 wasawi

Hello!

Totally not a naive question–video with websockets is still a little crazy. It could be the size of the messages, or the speed; I've worked a lot lately to make ofxLibwebsockets work with huge messages, but it's perfectly possible there's an error on my side!

A few questions for you:

  • Can you post what the library is logging out when the connection closes?
  • Can you try the "blob" example? It'll be much, much easier for you on the javascript side

robotconscience avatar Feb 03 '16 15:02 robotconscience

P.S. To try an autoconnect scheme, check out ofxSpacebrew, which uses ofxLibwebsockets, for an example:

  • Catch the "onClose" event
    • Use the addListener on libwebsockets to catch event (all examples have this!) https://github.com/Spacebrew/ofxSpacebrew/blob/master/src/ofxSpacebrew.cpp#L284
    • Catch onClose: https://github.com/Spacebrew/ofxSpacebrew/blob/master/src/ofxSpacebrew.cpp#L551
  • On update(), check if connection is closed, how long it's been since you last tried to reconnect, and give it a shot if it's not been too long: https://github.com/Spacebrew/ofxSpacebrew/blob/master/src/ofxSpacebrew.cpp#L304

robotconscience avatar Feb 03 '16 15:02 robotconscience

Thank you so much for the great reply! I'll have a look at it now.

wasawi avatar Feb 04 '16 00:02 wasawi