Comments (6)
Hello! Looking into this right now.
Basically, it has to do with how the underlying library we use works. Basically, unless libwebsockets gets an official "close" from a server (a "clean" close event like someone manually closing the connection), it doesn't fire an event. It does, however, give you options for setting up the client with a timeout.
I need to do a bit of an overhaul to the ClientOptions to get this integrated, but if you'd like to test it now, add the following lines to around line 99 in Client.cpp:
info.ka_time = 1;
info.ka_probes = 1;
info.ka_interval = 1;
The bad news is that the timeouts are in seconds... So for me it took about 5 seconds (on OS X) to get a "close" event from turning my network off. You may be able to play with ka_probes
(how many times it tests the network) and ka_interval
(time between the checks) to get a more real time response.
from ofxlibwebsockets.
nice. i will try that tomorrow and report back.
thanks a bunch.
from ofxlibwebsockets.
i tried it but nothing happened. no onClose or anything else got called.
i placed it in bool Client::connect ( ClientOptions options )
right after:
info.port = CONTEXT_PORT_NO_LISTEN;
info.protocols = &lws_protocols[0];
info.extensions = libwebsocket_get_internal_extensions();
info.gid = -1;
info.uid = -1;
from ofxlibwebsockets.
Yep, that's the right spot. Hm!
What platform are you on? And what are you doing to spark the "onClose"? I was able to get it to fire by turning off my network, but it did take quite some time to do so. Not sure the best way to make it any faster.
If you change line 50 in Util.h from
ofLog( OF_LOG_VERBOSE, getCallbackReason(reason) );
to
ofLog( OF_LOG_ERROR, getCallbackReason(reason) );
You'll get a printout of all of the libwebsockets events. Try setting that then doing your test again; after 30-60 seconds you should see LWS_CALLBACK_CLOSED
, then the onClose
event get fired in your main app.
from ofxlibwebsockets.
just to note that with your original suggestion i do get reconnected successfully once i replug my ethernet cable. so, that helps a lot already.
ok will try you latest advice too.
thanks.
from ofxlibwebsockets.
About to push ability to set these params via ClientOptions. However, libwebsockets uses whatever your system defaults are on OpenBSD platforms (e.g. OS X). Setting "ka_time" to anything but 0 will at least check if alive periodically, but at whatever your global settings are.
On my machine (OS X 10.9.4), that timeout is about 30 seconds!
from ofxlibwebsockets.
Related Issues (20)
- File Upload Question
- Corrupted data server side?
- example_server_echo not able to load jquery from RPI3
- net::ERR_CONTENT_LENGTH_MISMATCH HOT 1
- The addon will not be compatible with ofx 0.10.0 in windows HOT 5
- compiling on rpi HOT 4
- Problem with ubuntu 18 and workaround HOT 2
- Current windows libs are 64-bit exclusively HOT 1
- When compiling on OS X: Undefined symbols for architecture x86_64: HOT 1
- SSL connection Issue
- Add 64-bit requirment note to Readme HOT 1
- Can the Video Blob examples be built on Windows 10 X64
- handling args.json has compile errors
- 'bool ofxTurboJpeg::compress<ofImage>(T &,int,unsigned long)': cannot convert argument 3 from 'unsigned long *' to 'unsigned long' example_server_blob C:\Users\Thea\Desktop\of_v0.9.7_vs_release\addons\ofxLibwebsockets\example_server_blob\src\ofApp.cpp 158
- Race condition
- crypto.a and ssl.a paths in addon_config.mk HOT 2
- Memory leak when sending a video as binary
- Error may be due to dependancy? HOT 2
- Feature Request - blocking methods for send() and receive()? HOT 1
- Why is it requring websockets.lib?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ofxlibwebsockets.