0

向 websocket 服务器发送消息时出现问题。

2020-06-15 17:06:51,830 INFO  [snc.mob.gro.myt.con.ws.MutinyWebsocket] (vert.x-eventloop-thread-6) erreur {}: io.netty.handler.codec.http.websocketx.WebSocketHandshakeException: Connection closed while handsh
ake in process                                                                                                                                                                                                  
        at io.vertx.core.http.impl.WebSocketHandshakeInboundHandler.channelInactive(WebSocketHandshakeInboundHandler.java:57)                                                                                   
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:260)                                                                                         
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:246)                                                                                         
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:239)                                                                                           
        at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelInactive(CombinedChannelDuplexHandler.java:418)                                                             
        at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:386)                                                                                                        
        at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:351)                                                                                                           
        at io.netty.handler.codec.http.HttpClientCodec$Decoder.channelInactive(HttpClientCodec.java:288)                                                                                                        
        at io.netty.channel.CombinedChannelDuplexHandler.channelInactive(CombinedChannelDuplexHandler.java:221)                                                                                                 
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:260)                                                                                         
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:246)                                                                                         
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:239)                                                                                           
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405)                                                                                                
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:260)                                                                                         
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:246)                                                                                         
        at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901)                                                                                                         
        at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:818)                                                                                                                      
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)                                                                                                           
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)                                                                                                   
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:497)                                                                                                                                         
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)                                                                                                         
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)                                                                                                                            
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)                                                                                                                
        at java.lang.Thread.run(Thread.java:748)                                                                                                                                                                

我尝试了一些 chrome 插件,一切正常。

这是我的代码:

public void send(final String  message){

        WebSocketConnectOptions wsoptions =  new WebSocketConnectOptions()
        .setSsl(Boolean.FALSE).setURI( "/" ).setPort( 9304 ).setHost( "myserver.com" );


        HttpClientOptions httpClientOptions = new HttpClientOptions(  )
        .setTrustAll( true ).setSsl( false );

        Uni< WebSocket > webSocketUni = vertx.createHttpClient(httpClientOptions).webSocket( wsoptions );

        webSocketUni
                .subscribe()
                .with(  a -> {
                            a.handler( data -> {

                                log.info( "server message {}", data.toString() );
                                a.writeTextMessageAndForget( message );

                            } );
                        },
                        e -> log.info( "erreur {}", e ))
        ;
    }

我不知道我的客户的握手问题是什么。

任何帮助真的很感激。

谢谢!

4

0 回答 0