0

I am developing a spring web chat application using stomp and sockjs. I uploaded the application in pivotal web services. I understand that it uses a different port i.e. 4443. Once I run the application the websocket losts connection to undefined

The following error comes into the console: Opening Web Socket...

WebSocket connection to

'wss://homeworkpavilion.cfapps.io:4443/chat/193/dqu_2erz/websocket' failed: Error during WebSocket handshake: Unexpected response code: 302

POST https://homeworkpavilion.cfapps.io/chat/193/_bhfpyma/xhr_streaming 500 (Internal Server Error)

POST https://homeworkpavilion.cfapps.io/chat/193/nys00vmj/xhr 500 (Internal Server Error)

Whoops! Lost connection to undefined

Pls help, this stuff is reaaaalyy bugging me

Sabby
  • 2,586
  • 2
  • 27
  • 41

1 Answers1

0

There is no permission to redirect to different port. You can bypass this restriction by setting all origins to allowed when registering your stomp endpoints. I want to point out, that this is a very bad solution. You should take advantage of proxies, but I lack information here to help you with that.

Here is the code you might find useful:

public void registerStompEndpoints(StompEndpointRegistry registry) {
   registry.addEndpoint("/your_endpoint").setAllowedOrigins("*").withSockJS();
}
Astrowie
  • 195
  • 2
  • 17
  • Thanks, I actually did that. But now it bring the a 403 error, Error during WebSocket handshake: Unexpected response code: 403 – user2421982 Dec 12 '15 at 14:17
  • There is also a nice tutorial of this on official spring website here: [https://spring.io/blog/2015/01/20/the-resource-server-angular-js-and-spring-security-part-iii](https://spring.io/blog/2015/01/20/the-resource-server-angular-js-and-spring-security-part-iii) – Astrowie Jul 13 '16 at 07:24