2 Replies Latest reply on Dec 4, 2013 3:14 AM by Maelig Gohin

    Websockets timeout ?

    Maelig Gohin Newbie



      I've just found a serious problem (I lost lot of hairs today on it).


      I use websockets between my java app and the javascript front. The connection is ok, websocket opens et communication's good. But if the front user kill his tab/browser, the websocket isn't clearly closed (the method @OnClose isn't called server side).

      So when the server tries to send a message to this user, it's just go somewhere I don't know, no exception raised ...


      The workaround I've found is to clearly close the websocket on front side with (only working if browser process isn't hard killed) :


      window.onbeforeunload = function(){

              $scope.websocket.onclose = function () {}; // disable onclose handler first




      But is there any way to declare a timeout on the websocket ? If the server can't send it's message within X secondes, it raises an exception ?