L lte5000 Member Licensed User Longtime User Sep 11, 2015 #1 Hi, I am running a B4J webapp server on one of my PCs. I've had Internet Explorer and Chrome clients connected for a day or so with no issues. However, when I connect with Firefox or Safari, the websocket session will almost always terminate in less than 10 minutes. The B4J server will fire the WebSocket_Disconnected event. On the client side, I added this code to the b4j_ws.js file: Code: Copy b4j_ws.onclose = function(){ console.log('websocket disconnected!'); //try to reconnect in 10 seconds setTimeout(function(){b4j_connect(absolutePath);}, 10000); }; However, this function never fires in the client, so the client will never know that the websocket session has terminated. The problem is very puzzling to me because it seemingly only occurs in certain browsers. I can try to post more code if needed. Thanks for your input!
Hi, I am running a B4J webapp server on one of my PCs. I've had Internet Explorer and Chrome clients connected for a day or so with no issues. However, when I connect with Firefox or Safari, the websocket session will almost always terminate in less than 10 minutes. The B4J server will fire the WebSocket_Disconnected event. On the client side, I added this code to the b4j_ws.js file: Code: Copy b4j_ws.onclose = function(){ console.log('websocket disconnected!'); //try to reconnect in 10 seconds setTimeout(function(){b4j_connect(absolutePath);}, 10000); }; However, this function never fires in the client, so the client will never know that the websocket session has terminated. The problem is very puzzling to me because it seemingly only occurs in certain browsers. I can try to post more code if needed. Thanks for your input!
R Roycefer Well-Known Member Licensed User Longtime User Sep 11, 2015 #2 Try changing the signature to Code: Copy b4j_ws.onclose = function(event) {....} It works for me. Also, are you implementing a heartbeat? Upvote 0
Try changing the signature to Code: Copy b4j_ws.onclose = function(event) {....} It works for me. Also, are you implementing a heartbeat?
L lte5000 Member Licensed User Longtime User Sep 11, 2015 #3 Roycefer said: Try changing the signature to Code: Copy b4j_ws.onclose = function(event) {....} It works for me. Also, are you implementing a heartbeat? Click to expand... Just to clarify, b4j_ws.onclose does run when I stop the server, etc. It just doesn't run when the problem (described above) occurs on Firefox/Safari. As for a heartbeat, I call this function every five minutes, to keep the connection alive: Code: Copy Public Sub KeepAlive() Dim ft1 As Future = cb1.GetVal ws.Flush End Sub Should I be doing something differently here, or running it more often? Thanks! Upvote 0
Roycefer said: Try changing the signature to Code: Copy b4j_ws.onclose = function(event) {....} It works for me. Also, are you implementing a heartbeat? Click to expand... Just to clarify, b4j_ws.onclose does run when I stop the server, etc. It just doesn't run when the problem (described above) occurs on Firefox/Safari. As for a heartbeat, I call this function every five minutes, to keep the connection alive: Code: Copy Public Sub KeepAlive() Dim ft1 As Future = cb1.GetVal ws.Flush End Sub Should I be doing something differently here, or running it more often? Thanks!
R Roycefer Well-Known Member Licensed User Longtime User Sep 11, 2015 #4 If you're running your heartbeat every 5 minutes and the connection dies at around 10 minutes, I suspect it's probably not a heartbeat issue. I tried to replicate the issue with Firefox and wasn't able to. Have you used FireBug to try to pin down the issue in Firefox? Last edited: Sep 11, 2015 Upvote 0
If you're running your heartbeat every 5 minutes and the connection dies at around 10 minutes, I suspect it's probably not a heartbeat issue. I tried to replicate the issue with Firefox and wasn't able to. Have you used FireBug to try to pin down the issue in Firefox?
L lte5000 Member Licensed User Longtime User Sep 12, 2015 #5 Roycefer said: If you're running your heartbeat every 5 minutes and the connection dies at around 10 minutes, I suspect it's probably not a heartbeat issue. I tried to replicate the issue with Firefox and wasn't able to. Have you used FireBug to try to pin down the issue in Firefox? Click to expand... I changed the interval to 1 minute and it seems to have solved the problem. Thanks for your help Roycefer! Upvote 0
Roycefer said: If you're running your heartbeat every 5 minutes and the connection dies at around 10 minutes, I suspect it's probably not a heartbeat issue. I tried to replicate the issue with Firefox and wasn't able to. Have you used FireBug to try to pin down the issue in Firefox? Click to expand... I changed the interval to 1 minute and it seems to have solved the problem. Thanks for your help Roycefer!
R Roycefer Well-Known Member Licensed User Longtime User Sep 12, 2015 #6 Were your connections dying before 5 minutes, then? Upvote 0
L lte5000 Member Licensed User Longtime User Sep 12, 2015 #7 Apparently that was the case. My b4j server log did not always show that they died in less than 5 minutes - sometimes it was 6 or more minutes till it showed the client had disconnected. I do not know very much about websockets, but apparently there can be some delay between when the connection actually dies and when the server 'knows" that it has died. Upvote 0
Apparently that was the case. My b4j server log did not always show that they died in less than 5 minutes - sometimes it was 6 or more minutes till it showed the client had disconnected. I do not know very much about websockets, but apparently there can be some delay between when the connection actually dies and when the server 'knows" that it has died.