spring-websocket-portfolio icon indicating copy to clipboard operation
spring-websocket-portfolio copied to clipboard

stomp proxy

Open alleywind opened this issue 10 years ago • 4 comments

Is there any application like httpd or nginx which could proxy stomp protocol?

alleywind avatar May 28 '14 05:05 alleywind

you can configure HAproxy to work with websockets http://blog.silverbucket.net/post/31927044856/3-ways-to-configure-haproxy-for-websockets

th3sly avatar May 28 '14 06:05 th3sly

Working config snippet for nginx:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

[...]

        location /bus {
            proxy_read_timeout 999999999;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_pass http://127.0.0.1:8080;
       }

Bessonov avatar Jan 02 '15 20:01 Bessonov

I used nginx configuration which is presented above, but it didn't work for me in Google Chrome and worked in Firefox only through xhr (for websocket it returned 403). To solve this issue I've added setAllowedOrigins("http://mydomain") to my registered endpoint:

@Configuration
@EnableScheduling
@ComponentScan("org.springframework.samples")
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/portfolio").setAllowedOrigins("http://mydomain").withSockJS();
    }
    ...
}

See https://github.com/rstoyanchev/spring-websocket-portfolio/blob/5c898599d7fe75d2d852ac5accd2721640803726/src/main/java/org/springframework/samples/portfolio/config/WebSocketConfig.java#L36-L39 Hope, this will help to somebody :)

idelpivnitskiy avatar Apr 29 '15 13:04 idelpivnitskiy

Hi @idelpivnitskiy , this definitely helped me, thank you :)

ianaz avatar Oct 15 '15 07:10 ianaz