WebSocket with Spring backend loses connection after a while, onclose is not called -


in our spring application of controllers protected oauth security. websockets behind basic. before accessing websocket logged user asks username , hashed password websocket connection. both going generated, testing purposes returns same creditentials.

url info looks follows:

 https://user:debaee4affbeaba909a184066981d55a@localhost:8000/project-name/chat/info 

websocket opened properly. can send few messages , go trough broker , displayed users. here's request info chrome tools:

remote address:127.0.0.1:8000 request url:https://benny:debaee4affbeaba909a184066981d55a@localhost:8000/project-name/chat/033/7szz8k_f/xhr_send request method:post status code:204 no content  response headers: http/1.1 204 no content server: apache-coyote/1.1 x-content-type-options: nosniff x-xss-protection: 1; mode=block cache-control: no-cache, no-store, max-age=0, must-revalidate pragma: no-cache expires: 0 strict-transport-security: max-age=31536000 ; includesubdomains x-frame-options: deny access-control-allow-origin: https://localhost:8000 access-control-allow-credentials: true vary: origin content-type: text/plain;charset=utf-8 date: mon, 15 jun 2015 08:22:43 gmt connection: keep-alive  request headers: post /project-name/chat/033/7szz8k_f/xhr_send http/1.1 host: localhost:8000 connection: keep-alive content-length: 143 origin: https://localhost:8000 user-agent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36 content-type: text/plain;charset=utf-8 accept: */* referer: https://localhost:8000/ accept-encoding: gzip, deflate accept-language: en-us,en;q=0.8,pl;q=0.6 cookie: jsessionid=ff967d3dd1247c1d572c15cf8a3d5e8e; i18next=en; language=pl; tmhdynamiclocale.locale=%22pl-pl%22  ["send\npriority:9\ndestination:/random/chat/1/funny\ncontent-length:49\n\n{\"message\":\"sfsdf\",\"display\":\"the great wizard.\"}\u0000"] 

but after minute or when sending request 404 response. doesn't matter if send requests issued before. can write 50+ messages in time span , 404.

sample 404 request data follows:

remote address:127.0.0.1:8000 request url:https://hill:debaee4affbeaba909a184066981d55a@localhost:8000/project-name/chat/033/7szz8k_f/xhr_send request method:post status code:404 not found  response headers: http/1.1 404 not found server: apache-coyote/1.1 x-content-type-options: nosniff x-xss-protection: 1; mode=block cache-control: no-cache, no-store, max-age=0, must-revalidate pragma: no-cache expires: 0 strict-transport-security: max-age=31536000 ; includesubdomains x-frame-options: deny content-length: 0 date: mon, 15 jun 2015 08:24:17 gmt connection: keep-alive  request headers: post /project-name/chat/033/7szz8k_f/xhr_send http/1.1 host: localhost:8000 connection: keep-alive content-length: 143 origin: https://localhost:8000 user-agent: mozilla/5.0 (x11; linux x86_64) applewebkit/537.36 (khtml, gecko) chrome/41.0.2272.89 safari/537.36 content-type: text/plain;charset=utf-8 accept: */* referer: https://localhost:8000/ accept-encoding: gzip, deflate accept-language: en-us,en;q=0.8,pl;q=0.6 cookie: jsessionid=ff967d3dd1247c1d572c15cf8a3d5e8e; i18next=en; language=pl; tmhdynamiclocale.locale=%22pl-pl%22  request payload: ["send\npriority:9\ndestination:/random/chat/1/funny\ncontent-length:49\n\n{\"message\":\"yhgfh\",\"username\":\"the great wizard.\"}\u0000"] 

when setting stomp setup function react onclose:

socket.client = new sockjs(targeturl); socket.stomp = stomp.over(socket.client); socket.stomp.connect({}, startlistener); socket.stomp.onclose = reconnect; 

with reconnect function looking this(it's in angularjs):

var reconnect = function() {                     $log.debug('reconnect called');                     $timeout(function() {                         initialize();                     }, this.reconnect_timeout); }; 

but function never called.

controller chat pretty simple:

@controller public class stagechatcontroller {      @inject     private simpmessagingtemplate template;      @inject     private chatmessagerepository chatmessagerepository;  @messagemapping("/chat/{channel}/{type}")     public void sendmessage(@destinationvariable long channel, @destinationvariable chattype type, chatmessagedto message) {         chatmessage chatmessage = new chatmessage();          chatmessage.setdatestamp(localdatetime.now());         chatmessage.setmessage(message.getmessage());         chatmessage.setchannelid(channel);         chatmessage.setchattype(type);         chatmessage.setdisplayname(message.getdisplay());          chatmessage = this.chatmessagerepository.save(chatmessage);          this.template.convertandsend("/channel/" + project + "/" + type, chatmessage);     } 

security chat overrides oauth security chat urls:

@configuration     @enablewebsecurity     @order(2)     static class basicaccessconfig extends websecurityconfigureradapter {          @inject         private oauth2clientcontextfilter oauth2clientcontextfilter;          @value("${project.name.chat.token}")         private string chat_token;          @override         protected void configure(httpsecurity http) throws exception {             //@formatter:off             http             .requestmatcher(new antpathrequestmatcher("/chat/**/*"))             .authorizerequests().anyrequest().authenticated()             .and()             .httpbasic()             .and()             .anonymous().disable()             .csrf().disable()             .addfilterbefore(this.oauth2clientcontextfilter, securitycontextpersistencefilter.class);             ;             //@formatter:on         }          @override         public void configure(websecurity web) throws exception {             web.ignoring().antmatchers("/assets/**");         }          @override         protected void configure(authenticationmanagerbuilder auth) throws exception {             auth.inmemoryauthentication().withuser("hill").password(this.chat_token).authorities("read_chat");         }     } 


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -