1


I am having websocket in java which sends few message (5 -10) every second to javascript websocket client which then displays using angular ui-grid.

The problem is that after 20-30 minutes, the browser(IE,Firefox, chrome) stops receiving the messages.

  • What can be the issue?
  • What is the default session timeout value for javax.websocket.Session?
  • What settings/values should I check for e.g. getMaxTextMessageBufferSize() etc.
dryairship
  • 6,022
  • 4
  • 28
  • 54
yogi
  • 91
  • 2
  • 11
  • c++ application ,which sends messages, runs on separate server & java application server, which contains the java websocket, runs on separate server. when client(browser) is run from same server (java/tomcat) there is no issue. But if browser is run from different machine the issue arises, the java websocket session is closed with NORMAL_CLOSURE. The issue seems to be packet dropping. Please edit the question to add this info – yogi Feb 16 '16 at 09:26

2 Answers2

0

Check out if getMaxIdleTimeout() / setMaxIdleTimeout() is what you're looking for.

From the javax.websocket.Session docs on setMaxIdleTimeout():

Set the non-zero number of milliseconds before this session will be closed by the container if it is inactive, ie no messages are either sent or received. A value that is 0 or negative indicates the session will never timeout due to inactivity.

archived
  • 647
  • 8
  • 24
  • This may not be required as session is never idle, there are few messages send per every second. Anyway now I am setting setMaxIdleTimeout to zero. – yogi Feb 16 '16 at 10:57
0

The issue was with communication link ( wire connectivity). I resolved the issue by reconnecting to websocket on websocket.onclose (client side javascript code). The onclose is called when websocket session is closed. I reconnect by calling connect() function inside onclose.

This answer also helped a lot. AngularJS: Reconnect WebSocket inside a service

Community
  • 1
  • 1
yogi
  • 91
  • 2
  • 11