各位大神!
    有没有在写app时遇到这个问题,长连接成功后数据接收成功,但是有一个大于1k的数据没有接收到,小数据正常。我抓包的结果是数据正常获取的,但是在Websocket中打印不出来。我用的是Java-WebScoket1.3.1-SNAPSHOT这个版本的框架;大神们谁能回复下。或是有别的框架推荐下,小弟新手,不胜感激
 

解决方案 »

  1.   

    我想问问长连接怎么创建 怎么判断socket连接状态
      

  2.   

    1.用框架的话,会有连接成功的回调方法:
    2.自己new的话,new完发个消息出来,收到说明连接成功
      

  3.   

    我也遇到了,web客户端没啥问题,我发送的是一段音频的base64字节码,java做的客户端接收不全java-websocket-1.3.3.jar
    package com.webSoket.client;import java.net.URI;
    import java.net.URISyntaxException;import org.java_websocket.client.WebSocketClient;
    import org.java_websocket.drafts.Draft;
    import org.java_websocket.drafts.Draft_17;
    import org.java_websocket.framing.Framedata;
    import org.java_websocket.handshake.ServerHandshake;/** This example demonstrates how to create a websocket connection to a server. Only the most important callbacks are overloaded. */
    public class ExampleClient extends WebSocketClient { public ExampleClient( URI serverUri , Draft draft ) {
    super( serverUri, draft );
    } public ExampleClient( URI serverURI ) {
    super( serverURI );
    } @Override
    public void onOpen( ServerHandshake handshakedata ) {
    System.out.println( "opened connection" );
    // if you plan to refuse connection based on ip or httpfields overload: onWebsocketHandshakeReceivedAsClient
    } @Override
    public void onMessage( String message ) {

    System.out.println( "received: " + message);
    } @Override
    public void onFragment( Framedata fragment ) {
    System.out.println( "received fragment: " + new String( fragment.getPayloadData().array() ) );
    } @Override
    public void onClose( int code, String reason, boolean remote ) {
    // The codecodes are documented in class org.java_websocket.framing.CloseFrame
    System.out.println( "Connection closed by " + ( remote ? "remote peer" : "us" ) );
    } @Override
    public void onError( Exception ex ) {
    ex.printStackTrace();
    // if the error is fatal then onClose will be called additionally
    } public static void main( String[] args ) throws URISyntaxException {
    ExampleClient c = new ExampleClient( new URI( "ws://localhost:8080/webSocketTest/echo?username=zhukaibo" ), new Draft_17() ); // more about drafts here: http://github.com/TooTallNate/Java-WebSocket/wiki/Drafts
    c.connect();
    }}
      

  4.   

    我改用了大神写的库,没用jar包,
      

  5.   

    你是用java_websocket的源码解决的,还是用谁的库解决的,能告诉在下是怎么解决的吗?