spring boot rest and angular2 with websocket (stomp over sockjs)
<p>Is it possible to use stomp over sockjs without MVC. So I would like to have spring rest interface in tomcat, and angular2 application run by express.</p>

<p><strong>WebSocketConfig.java</strong></p>

<pre><code>@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {

    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        // the endpoint for websocket connections
        registry.addEndpoint("/portfolio").setAllowedOrigins("*").withSockJS();
    }

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

<p><strong>SocketController.java</strong></p>

<pre><code>@Controller
public class SocketController {

    @Autowired
    private SimpMessagingTemplate template;

    public SocketController() {
        int a = 5;
    }

    @MessageMapping("/greeting")
    public String handle(String greeting) {
        return "[" + "greeting" + ": " + greeting;
    }
}
</code></pre>

<p>and typescript code:</p>

<p>.
.
.    </p>

<pre><code>constructor() {

        var socket = new SockJS('http://localhost:8080/portfolio');
        this.stompClient = Stomp.over(socket);
        this.stompClient.connect("guest", "guest", function(frame) {
            console.log('Connected: ' + frame);
            this.stompClient.subscribe('http://localhost:8080/topic/greeting', function(greeting) {
                console.log("from from", greeting);
            });
        }, function (err) {
            console.log('err', err);
        });
    }
</code></pre>

<p>.
.
.</p>

<pre><code>send() {
    this.stompClient.send("http://localhost:8080/app/greeting", {}, JSON.stringify({ 'name': "kitica" }));
}
</code></pre>

<p>.
.
.</p>

<p>but for some reason this is not working.. in console I get output:</p>

<pre><code>Opening Web Socket...
stomp.js:134 Web Socket Opened...
stomp.js:134 &gt;&gt;&gt; CONNECT
login:guest
passcode:guest
accept-version:1.1,1.0
heart-beat:10000,10000



stomp.js:134 &lt;&lt;&lt; CONNECTED
version:1.1
heart-beat:0,0



stomp.js:134 connected to server undefined
activity-socket.ts:17 Connected: CONNECTED
heart-beat:0,0
version:1.1
</code></pre>

<p>and when I send I get</p>

<pre><code>&gt;&gt;&gt; SEND
destination:http://localhost:8080/app/greeting
content-length:17
</code></pre>

<p>{"name":"kitica"}</p>

<p>but message never comes back to subscriber.</p>

<p>angular2 is on port 8001 and spring rest is on 8080</p>