2013-07-17 4 views
0

아파치 미나와 웹 소켓 통신에 문제가 있습니다.java apache mina websocket communication

핸드 셰이크가 제대로 작동하고 내 서버와의 연결이 제대로 작동하지만 클라이언트가 내 서버에 문자열을 보내면 문자열이 수신되지만 콘솔에 표시 할 수 없습니다.

public void messageReceived(IoSession session, Object message) throws Exception { 
System.out.println(message.toString()); 
if(message.toString().length() > 20 && message.toString().substring(0, 17).equals("Sec-WebSocket-Key")) { 
    new Thread(new WebsocketHandler(session, message)).start(); 
} else { 
    // 
}} 

내 서버에 로그 메시지

INFO를 수신 말한다받은 : HeapBuffer [POS = 0 LIM = 10 캡 = 2048 : 81 84 88 45 (b) (31) DC 00 78 65]

하지만 메시지를 표시 할 수 없다, 내 TextLineCodecFactory 필터라고 생각하지만 이유는 모르겠다.

인사

답변

0

추가 위해 "\ r \ n"을 쓰기.

byte[] bytes = content.getBytes("UTF-8"); 
 
outputStream.write(bytes); 
 
outputStream.write("\r\n".getBytes());