dk2k / websocket-server

Used technologies: maven, SockJS + stomp, spring boot and some more from spring stack, hibernate, MySQL, thymeleaf, c3p0
0 stars 0 forks source link

lost connect to stompEndPoint #1

Open mastershashi opened 6 years ago

mastershashi commented 6 years ago

Hi ,

For me Socket JS is unable to make a connection with the server in cloud foundry . here is my code var socket = new SockJS('/websocket-example'); stompClient = Stomp.over(socket); stompClient.connect({}, function (frame) { setConnected(true); console.log('Connected: ' + frame); showGreeting("Connected"); stompClient.send("/app/user", {}, JSON.stringify({'name': $("#name").val()})); if (stompClient !== null) { stompClient.disconnect(); } setConnected(false); console.log("Disconnected"); });

In Localhost it is working fine but in in cloud foundry it is not working it unable to establish the connection Log: Opening Web Socket...

2sockjs.min.js:2 GET https://websocket-cf.cfapps.ondemand.com/websocket-example/info?t=1536215752774 404 (Not Found) r._start @ sockjs.min.js:2 (anonymous) @ sockjs.min.js:2 setTimeout (async) r @ sockjs.min.js:2 n @ sockjs.min.js:3 n @ sockjs.min.js:2 n._getReceiver @ sockjs.min.js:2 n.doXhr @ sockjs.min.js:2 (anonymous) @ sockjs.min.js:2 setTimeout (async) n @ sockjs.min.js:2 r @ sockjs.min.js:2 sendName @ app.js:37 (anonymous) @ app.js:67 dispatch @ jquery.js:5110 q.handle @ jquery.js:4918 localhost/:1 Failed to load https://websocket-cf.cfapps.sap.hana.ondemand.com/websocket-example/info?t=1536215752774:

Can you please tell me what could be the possible reason for this ?

dk2k commented 6 years ago

Hi mastershashi, I can just point a couple of directions. Please check out how the WAR got deployed on websocket-cf.cfapps.sap.hana.ondemand.com. Can it be that the context /websocket-example differs? May be the app was deployed this way: https://websocket-cf.cfapps.sap.hana.ondemand.com/info?t=1536215752774 - with empty context? Or with additional level in context, say https://websocket-cf.cfapps.sap.hana.ondemand.com/my_apps/websocket-example/info?t=1536215752774 Was the app deployed on port 80? Maybe you need to specify a port explicitly? Are there any access restrictions on the cloud? Is port 8080 open? And the common advice: search for the difference between localhost and cloud deployments.