xhr#U流媒体传输失败(Spring+;Zuul+;SockJS)

xhr#U流媒体传输失败(Spring+;Zuul+;SockJS),spring,netflix-zuul,spring-cloud-netflix,sockjs,Spring,Netflix Zuul,Spring Cloud Netflix,Sockjs,我得到了以下测试脚本(使用node执行,real client是浏览器,结果相同): const SockJS=require('SockJS-client'); const webtomp=require('webtomp-client'); 让sock=newsockjs(/*在此处插入URL*/); 让我们跺一下{ 心跳:错, }); connect({},function(){ console.log('connected'); },函数(){ console.log('disconne

我得到了以下测试脚本(使用node执行,real client是浏览器,结果相同):

const SockJS=require('SockJS-client');
const webtomp=require('webtomp-client');
让sock=newsockjs(/*在此处插入URL*/);
让我们跺一下{
心跳:错,
});
connect({},function(){
console.log('connected');
},函数(){
console.log('disconnected');
});
正在使用的版本:

  • 弹簧防尘套-1.5.3
  • SpringCloudNetflix-1.3.1
  • Nginx-1.11
  • RabbitMQ-3.6.9
为了排除我们的部分基础设施(如NGINX作为路由子域的代理等)是罪恶的根源,我尝试通过NGINX代理和Zuul直接连接到基于Spring的Stomp代理中继(使用RabbitMQ作为真正的代理)

前两个变体按预期工作,但第三个变体(使用Zuul作为带有ResourceServer注释的网关)失败。增加超时时间没有帮助,因为问题似乎在于“握手”。这是迄今为止我从客户端日志中得到的信息(前两个变体的日志,一切正常,甚至可以建立WebTomp):

我希望任何人都有办法解决这个问题。似乎Zuul或其他东西没有返回sockjs响应。即使在服务器端使用跟踪也没有显示任何错误

网关本身是一个简单的设置,具有
@springbootcapplication
@EnableZuulProxy
@EnableResourceServer
和以下配置:

# increase the timeout of the proxy
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
ribbon:
  ConnectTimeout: 3000
  ReadTimeout: 60000
zuul:
  host:
    connect-timeout-millis: 3000
    socket-timeout-millis: 60000
  # We don't want to automatically register all service available on Eureka
  ignored-services: "*"
  retryable: true
  # Default is "Cookie,Set-Cookie,Authorization", but we want to forward the Bearer Token
  sensitive-headers: Cookie,Set-Cookie
  routes:
    stomp:
      path: /stomp/**
      serviceId: stomp
      strip-prefix: true

我遇到了同样的问题。你解决这个问题了吗?我发现Zuul不支持长轮询(例如:websocket)。很抱歉,我不再从事此项目。似乎没有解决办法
sockjs-client:main using url http://domain.tld/stomp +0ms
  sockjs-client:utils:url same http://domain.tld/stomp http://localhost/ false +4ms
  sockjs-client:info-receiver http://domain.tld/stomp +3ms
Opening Web Socket...
  sockjs-client:info-receiver doXhr http://domain.tld/stomp/info +8ms
  sockjs-client:driver:xhr GET http://domain.tld/stomp/info undefined +1ms
  sockjs-client:driver:xhr data {"entropy":886967672,"origins":["*:*"],"cookie_needed":true,"websocket":false} +280ms
  sockjs-client:driver:xhr end +3ms
  sockjs-client:info-receiver finish { entropy: 886967672,
  origins: [ '*:*' ],
  cookie_needed: true,
  websocket: false } 284 +1ms
  sockjs-client:info-receiver _cleanup +4ms
  sockjs-client:main _receiveInfo 284 +1ms
  sockjs-client:main info { entropy: 886967672,
  origins: [ '*:*' ],
  cookie_needed: true,
  websocket: false,
  nullOrigin: false,
  sameOrigin: false,
  sameScheme: false } +1ms
  sockjs-client:utils:transport disabled from server websocket +2ms
  sockjs-client:utils:transport enabled xhr-streaming +1ms
  sockjs-client:utils:transport disabled xdr-streaming +0ms
  sockjs-client:utils:transport enabled eventsource +0ms
  sockjs-client:utils:transport disabled iframe-eventsource +1ms
  sockjs-client:utils:transport disabled htmlfile +0ms
  sockjs-client:utils:transport disabled iframe-htmlfile +0ms
  sockjs-client:utils:transport enabled xhr-polling +0ms
  sockjs-client:utils:transport disabled xdr-polling +0ms
  sockjs-client:utils:transport disabled iframe-xhr-polling +1ms
  sockjs-client:utils:transport disabled jsonp-polling +0ms
  sockjs-client:main 3 enabled transports +0ms
  sockjs-client:main attempt xhr-streaming +6ms
  sockjs-client:main using timeout 2272 +0ms
  sockjs-client:main transport url http://domain.tld/stomp/490/5sugacsu +0ms
  sockjs-client:sender-receiver http://domain.tld/stomp/490/5sugacsu/xhr_streaming +1ms
  sockjs-client:buffered-sender http://domain.tld/stomp/490/5sugacsu +0ms
  sockjs-client:polling http://domain.tld/stomp/490/5sugacsu/xhr_streaming +0ms
  sockjs-client:polling _scheduleReceiver +0ms
  sockjs-client:receiver:xhr http://domain.tld/stomp/490/5sugacsu/xhr_streaming +0ms
  sockjs-client:driver:xhr POST http://domain.tld/stomp/490/5sugacsu/xhr_streaming null +1ms
  sockjs-client:main _transportTimeout +2s
  sockjs-client:main _transportClose undefined 2007 Transport timed out +0ms
  sockjs-client:main attempt eventsource +0ms
  sockjs-client:main using timeout 2272 +1ms
  sockjs-client:main transport url http://domain.tld/stomp/490/s50jl3qh +1ms
  sockjs-client:sender-receiver http://domain.tld/stomp/490/s50jl3qh/eventsource +0ms
  sockjs-client:buffered-sender http://domain.tld/stomp/490/s50jl3qh +0ms
  sockjs-client:polling http://domain.tld/stomp/490/s50jl3qh/eventsource +0ms
  sockjs-client:polling _scheduleReceiver +1ms
  sockjs-client:receiver:eventsource http://domain.tld/stomp/490/s50jl3qh/eventsource +0ms
  sockjs-client:receiver:eventsource error 0 Event { type: 'error' } +28ms
  sockjs-client:receiver:eventsource cleanup +1ms
  sockjs-client:receiver:eventsource close network +0ms
  sockjs-client:polling close null network undefined +202ms
  sockjs-client:polling _scheduleReceiver +0ms
# increase the timeout of the proxy
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000
ribbon:
  ConnectTimeout: 3000
  ReadTimeout: 60000
zuul:
  host:
    connect-timeout-millis: 3000
    socket-timeout-millis: 60000
  # We don't want to automatically register all service available on Eureka
  ignored-services: "*"
  retryable: true
  # Default is "Cookie,Set-Cookie,Authorization", but we want to forward the Bearer Token
  sensitive-headers: Cookie,Set-Cookie
  routes:
    stomp:
      path: /stomp/**
      serviceId: stomp
      strip-prefix: true