2016-10-17 8 views
0

내가 구르기 클라이언트를 사용하여 요청을 보내고 때, 로그 출력은, 테야을 사용하여 웹 소켓 클라이언트를 쓰고 있어요 :WebSocketAnnotationMethodMessageHandler 일치하는 방법

15:17:44.688]-[clientInboundChannel-59]-[org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler]-{Searching methods to handle SEND /app/vehicle session=qnlerizz} 
15:17:44.688]-[clientInboundChannel-59]-[org.springframework.web.socket.messaging.WebSocketAnnotationMethodMessageHandler]-{No matching methods.} 

이 클라이언트가 문제가되지 않습니다 보여줍니다.

public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer { 

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

    @Override 
    public void registerStompEndpoints(StompEndpointRegistry registry) { 
     registry.addEndpoint("/vehicle").withSockJS();   
    } 
} 

이가이다 : 이것은 내 웹 구성

@Controller 
@Log4j2 
public class WebSocketController { 

    public SimpMessagingTemplate template; 

    @Autowired 
    public WebSocketController(SimpMessagingTemplate template) { 
     this.template = template; 
    }  

    @MessageMapping("/vehicle") 
    @SendTo("/topic/location") 
    public void getloc() throws Exception { 
     try { 
      for (int i = 0; i < 10; i++) { 
       template.convertAndSend("/topic/location", "aaaaaaa"); 
      } 
     } catch (Exception e) { 
      log.error(e); 
     } 
    } 
} 

입니다 : 그리고 서버는 이미 핸들 method.This 있었다 오전 request.But을 처리하기 위해 일치하는 URL을 코드입니다 찾을 수 없습니다 고객 코드 :

function connect() { 
     var socket = new SockJS('/clbs/vehicle'); 
     stompClient = Stomp.over(socket); 
     stompClient.connect({}, function (frame) { 
      setConnected(true); 
      console.log('Connected: ' + frame); 
      stompClient.subscribe('/topic/location', function (greeting) { 
       showGreeting(JSON.parse(greeting.body).content); 
      }); 
     }); 
    } 

stompClient.send("/app/vehicle",{},JSON.stringify("bbb")); 

어떻게해야합니까?

추 신 : 컨트롤러 WebSocketController은 이미 자동 스캔입니다.

JDK : 1.8 톰캣 : 8.0.36 봄 : 4.2.6

나는 이일이 질문에 대한 투쟁이다.

답변

0

컨트롤러가 자동으로 성공적으로 스캔되었는지 확인하십시오. 빈이 scan.So가 stomp 클라이언트 요청을 처리하는 속성 메소드와 일치하지 않기 때문에이 문제가 발생합니다. 자동 스캔 구성을 확인하십시오. 기록 로그 내용을 확인하십시오. , 여름 세부 사항은 here입니다.