-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Network connection interruption not detected #276
Comments
Hi @Javierd Hm... Interesting question... From one side — that seems to be the problem on websocket connection side.... But in the end — it doesn't matter for end user. Need to investigate this... |
Sure, although it's related to a fail on the websocket, the wamp client should get notified and try to reconnect. |
Well, if underlying websocket object reports the failure — wampy of course handles that: it reconnects if configured and so on. So as I see the problem is that websocket is not reporting the error/disconnection... |
Rgd
|
Yeah, I currently detect the current state using those callbacks, but I though it would be handy to have that isConnected method. Anyway, that is not importart. |
Well, I haven't got there yet, sorry. But I think the answer is somewhere deeper in the underlying network stack implementation. And afaik the only way to detect it — is a kind of keepalive/ping thing. In that case, when the browser/node tries to send a packet — it will face the problem from the network stack so all callback events will be fired as expected. Look for example at this SO: https://stackoverflow.com/questions/26971026/handling-connection-loss-with-websockets Oh, btw, what WAMP server/Router do you use? Look at docs, there might be an option to set the websocket ping/pong poll for connection. (of course that doesn't solve the problem for the client side, but still might be helpfull) Unfortunately, that low-level feature (ping/pong frames) is not available in the browser websocket object :( |
So my advice for a quickfix is to implement a kind of super lightweight dummy RPC (like But we may try to find a more universal solution... |
I'm currently using wampcc as the wamp server, and in fact I was planning on adding that kind of heartbeat RPC call. However, the problem is that once the client is disconnected, if I try to call a wamp RPC function, it never returns, so it doesn't event notice that it's disconnected in this way |
Hi @Javierd Unfortunately haven't had much time to get to look yet, but I think I have an idea where the problem might be. I'll try to take a look at it soon.... |
@Javierd can you try Wampy from the dev branch in your env? Hope it will resolve your issue. It will be very helpful if you can check that! |
I've been trying it but it doesn't seem to work. In case it helps you, my use case is the following one: Also, this problem may be related to the timeout option of wamp_client.call() method, which is not working neither in this scenario. I've solved it by using a new Promise with a timeout along with Promise.race |
Okay. Thnx for additional details. I tuned some things more. Will try to test it (actually that requires a bit more time, then just coding :) ) async _wsOnClose (event) {
this._log('websocket disconnected. Info: ', event);
await this._reject_ongoing_promises(new WebsocketError('Connection closed'));
......
} |
call timeout option must be processed on the router or callee side. Right now it is not processed on the wampy's side. |
@Javierd I have a next code: const wampy = new Wampy('ws://127.0.0.1:8080/ws', options);
await wampy.connect();
const p1 = wampy.call('test.rpc.com');
p1.catch(function (reason) {
console.log('catching:', reason);
});
await wampy.disconnect(); And |
I'll close it for now. Feel free to reopen in case of experiencing this again. |
Describe the bug
When the client is connected to a server and the client network fails (e.g., the data and wifi are disabled) the client never notices the problem, and when trying to execute a RPC call, the call never returns, and doesn't throw any errors neither.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The component should note that the connection is lost, it should retry to connect and, if it can't, it should call the onclose callback.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: