rstoyanchev / spring-websocket-portfolio

738 stars 444 forks source link

stomp proxy #39

Open alleywind opened 10 years ago

alleywind commented 10 years ago

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

th3sly commented 10 years ago

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

Bessonov commented 9 years ago

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;
       }
idelpivnitskiy commented 9 years ago

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 :)

ianaz commented 8 years ago

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