2015-11-09 687 views
4

我正在尝试使用带有角度和heroku的websocket rails。它正在开发中,但现在正在生产中。这里是发布事件的服务器代码和侦听它的客户端。在WebSocket握手期间出现错误:意外的响应代码:503

#Server 
WebsocketRails[channel_name].trigger('new_message', @json) 

//Client 
var dispatcher = new WebSocketRails(window.location.host + "/websocket"); 
var channel = dispatcher.subscribe(channel_name); 
channel.bind('new_message', function(data) { 
    $scope.$apply(function(){ 
    cr.unread_messages += 1; 
    }); 
}); 

我在生产SSL。我已经尝试设置

force_ssl = false 

production.rb,但无济于事。

我得到的错误是:

WebSocket connection to 'wss://domain.com/websocket' failed: Error during WebSocket handshake: Unexpected response code: 503 

回答

0

我有同样的问题,我的应用程序背后nginx的。 检查我的Nginx配置。

location/{ 
    proxy_pass http://localhost:8080; 
    proxy_http_version 1.1; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection "upgrade"; 
    proxy_set_header Host $host; 
} 
相关问题