Spring Webscoket error javax.websocket.DeploymentException: ошибка рукопожатия в nginx - PullRequest
0 голосов
/ 13 января 2020

Я использую spring-boot-starter-websocket и запускаю localhost - это успех. Но я работаю на сервере с Nginx, Spring Gateway не подключен.

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

  @Override
  public void configureMessageBroker(MessageBrokerRegistry registry) {
    registry.setApplicationDestinationPrefixes("/app");
    registry.enableSimpleBroker("/topic");
  }

  @Override
  public void registerStompEndpoints(StompEndpointRegistry registry) {
    registry.addEndpoint("/chat/").setAllowedOrigins("*")
        .setHandshakeHandler(new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy()));
  }

}

config:

  • Nginx порт 80
  • gateway-service порт 8000
  • порт службы сообщений 8540

клиент-> Nginx -> служба шлюза -> служба сообщений

Запуск localhost: ws: / /127.0.0.1:8540/chat/ в порядке. Запустите сервер: ws: //mydomain.xyz/message-service/chat/ error javax.websocket.DeploymentException: Handshake

Zull:

server:
  port: 8000

spring:
  application:
    name: gateway-service

zuul:
  ignoredServices: '*'
  host:
    connect-timeout-millis: 20000
    socket-timeout-millis: 20000
  routes:
    profile-service:
        path: /profile-service/**
        serviceId: profile-service
        stripPrefix: true
    message-service:
        path: /message-service/**
        serviceId: message-service
        stripPrefix: true

Ошибка:

run:
javax.websocket.DeploymentException: Handshake error.
false
    at org.glassfish.tyrus.client.ClientManager$1.run(ClientManager.java:446)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.glassfish.tyrus.client.ClientManager$SameThreadExecutorService.execute(ClientManager.java:620)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:351)
    at org.glassfish.tyrus.client.ClientManager.connectToServer(ClientManager.java:241)
    at sk.Main.setConnectWebsocket(Main.java:28)
    at sk.Main.main(Main.java:18)
Caused by: org.glassfish.tyrus.core.HandshakeException: Response code was not 101: 400
    at org.glassfish.tyrus.core.Handshake.validateServerResponse(Handshake.java:315)
    at org.glassfish.tyrus.client.TyrusClientEngine.processResponse(TyrusClientEngine.java:133)
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleHandshake(GrizzlyClientFilter.java:306)
    at org.glassfish.tyrus.container.grizzly.client.GrizzlyClientFilter.handleRead(GrizzlyClientFilter.java:280)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:547)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:748)
BUILD SUCCESSFUL (total time: 0 seconds)
...