Signalr inactivity timeout - javascript

I have googled many things related to this issue. I am doing signalr connection using WebSocket and longpooling, I am pinging the server every 30 sec from the connection.
When I load the first time, I don't doing anything on the page, no refresh, after some time connection is disconnected due to inactivity(he client has been inactive since 26/03/2018 30000ms and it has exceeded the inactivity timeout), and reconnected again as I have written reconnect function,
though if I calling ping method to server every 20 sec after some time server is disconnected and I don't know why.
I have enabled logging=true on client side,
my client is HTML page.
If the server is not reconnected, an error like
longpooling request is failed
occurs. On the server keepalive is null.
The first time the client is able to reconnect, but the second time not.
I don't know why the server disconnects, as I am using longpooling.
The ping method is an empty method only for the heartbeat I used.
The application is hosted using Amazon ELB.
Please help, I have tried for 3-4 days, but I could not find the issue.

Related

WebRTC delay on iceConnectionState - 'disconnected'

Two peers are connected - host and client
Client gets offline and iceConnectionState - 'disconnected' on host is triggered after about 3-7 seconds
Why is there a delay ? and how to remove that delay?
I just wanted get online status of user in realtime
Peer connection gets closed when there's no data coming for several seconds, hence the delay. There's no Web API to configure this timeout.
I see three ways how you might reduce the delay:
Send keepalives between peers via datachannel. If there were no keepalive for n milliseconds, client is considered disconnected; connection might be closed (or "pending" user status can be displayed).
Some timeout is still needed, but it can be shorter than the default one.
If client always sends the video, you might use getStats() to detect when there's no new packets coming => client disconnected. It's the same as 1, but using video packets instead of keepalive messages. See this answer.
Send a message to server when client is about to disconnect so the server knows connection is no longer needed and close it. For example, you could send a "goodbye" message to WebRTC datachannel in window.onbeforeunload callback. The drawback is that if client goes offline without closing the page you still have to wait for n seconds, whatever is default in your browser.

Change Firebase real time database ping pong time

a query related to firebase presence app using javascript sdk. I have seen that there is 60 seconds buffer after the internet is disconnected after which the entries are removed from the firebase real tim edatabase. Is it possible to configure this time from 60 seconds to lets say 30 seconds? . I basically want the entries to be removed from the presence as soon as the internet is disconnected. If not immediately then at least sooner than a minute alteast.Does anybody have any idea on this?
There are two ways an onDisconnect handler can be triggered on the Firebase servers:
A clean disconnect is when the client has time to inform the server that it is about to disconnect, and in that case the server executes the onDisconnect handlers immediately.
A dirty disconnect is when the client disconnects without informing the server. In this case the server detects that the client is gone when the socket from that client times out, and then it executes the onDisconnect handlers.
Detecting the dirty disconnects takes some times (upwards to a few minutes) and there's no way for you to configure it.
If you want more granular presence detection, the common approach is to periodically write a timestamp into the database from the client. This indicates when the client was last active, and can be used by the other clients to then indicate the liveliness of that user/client.

Signalr Reconnects every 2 seconds even thought server is up

So we have a signalr application that when the server has a hickup, the clients call "reconnect" every 2 seconds indefinitely (even though the server is back up). When the page refreshes it connects just fine. couples things that I noticed:
The reconnect request in the Network dev tools shows "Status Code: 101 Switching Protocols"
We're using ms-signalr-client for the wrapper around the javascript client, it runs "reconnect", then immediately is successful, then immediately closes the connection
This is causing our prod server to go down 3 or 4 times a day as soon as the clients lose connection for a second
Figured out the issue. there was an exception being thrown SILENTLY in the Reconnected Stack. not sure why considering the same code is called in the Connect Stack. anyway, reworked it that we don't have to make the same call, and not need it. works fine now

Socket.io when client Internet going to off

How can i callback from client to server internet going to off? I have users and i added their connections in the some room. But I can not know when they are Internet going to down. I want to callback their statues but I do not know how. My clients are android phone.
this function does not work.
socket.on("disconnect", function () {
var SocketRoom= socket.room;
socket.leave(SocketRoom);
});
The clients can't send a message through the socket connection, if they are not connected to the network/internet anymore. You might want to check for timeouts.
Once a client connects to the server, the server sends a message to the client in a fixed time interval (like every 5 seconds).
If the client responds to that message, you know, it's still conencted and continue with your program logic.
If the client does not respond to your message, then they are very likely not connected to the internet anymore (or are unreachable for other reasons). If this is the case, you can force them to leave the room (like in your socket.on("disconnect", ...) function).
Please note:
The higher the timeout interval, the less precise is the actual disconnect time, but the load on the connection is kept low.
If a client does not respond to a timeout-check, you might want to retry to send a message to that client a couple of times before force-closing the connection.

Web socket in VPC behind load-balancer giving errors

When I connect and send some sockets to my Linux, node.js server inside a VPC and behind a load balancer I get a unusually long delay, followed by WebSocket connection to [address] failed: Connection closed before receiving a handshake response
And then a few seconds later I get responses for all the sockets I sent, and then everything works fine. No long delays.
But just on this initial connect, there's a horrible wait followed by this error message. Everything still works, it just takes a bit.
I'm using Amazon Web Service EC2 load-balancers and AWS VPCs
When I'm accessing the same server directly, I get no delays.
I was unable to connect to my server when having just a load-balancer.
I was unable to connect to my server when having just a VPC, so I can't isolate the problem to just my load-balancer or the VPC.
What's going on?
The correct answer was Michael's comment that I marked as helpful.
The first person who puts this into an answer format gets points.
The health of connection from the Load Balancer to the server is determined by the way in which your Health Check is set up.
Try and set it up differently.
eg
Use a TCP based Health Check rather than a HTTP based one, and change the thresholds.
If you see some different behaviour, you'll know that the Health Check is the issue.
It is hard to know exactly without debugging, but note that there are issues on using Elastic Load Balancer for Web Sockets. They parse HTTP requests (unless in TCP mode) and they have a 60 seconds idle connection timeout.

Categories

Resources