websocket :Error during WebSocket handshake: Unexpected response code: 500

Mahdi5 years ago

i m using angular and i have done the authentification succesully
but when using the websocket i have got erorr .

 WebSocket connection to 'ws://52.232.22.124/api/socket' failed: Error during WebSocket handshake: Unexpected response code: 500
Matyi Szabolcs5 years ago

Hello!

I also care. What is the solution? Very disturbing!

Thanks

Jasiel Izaguirre4 years ago

Hello!

Did you find any solution for this?

jaroja44 years ago

Hi!
I have the same problem. Anyone found the solution?

I login with ajax like this:

get login() {
    $.ajax({
      type: 'POST',
      dataType: "json",
      data: {
        "email": "MY_USER",
        "password": "MY_PASSWD"
      },
      url: 'http://MY_URL:8082/api/session/',
      headers: {
          "Authorization": "Basic " + btoa("MY_USER" + ":" + "MY_PASS")
      },
      success: function (response) {
          console.log(response);
          mapTrack.openWebsocket;         
      }
    });

    get openWebsocket() {
      var socket;
      socket = new WebSocket('ws://MY_URL:8082/api/socket');
  
      socket.onclose = function (event) {
        console.log("WebSocket closed");
      };
  
      socket.onmessage = function (event) {
        mapTrack.markers(JSON.parse(event.data));
        //console.log(event.data);
      };
    }

The reponse is:

For the session function is:

Object
id: 89
attributes: {notificationTokens: "fQR5J86Wdb8:APA91bH1IwEB0DJuEzv4iQRWJd9tnpJ0HSU55U…VzJiB5Kkkj4f5B3jg1nsH0QW1S2yxy99ApZcYckaS0jsI0QQM"}
name: "prueba"
login: ""
email: "MY_EMAIL"
phone: ""
readonly: false
administrator: false
map: ""
latitude: 0
longitude: 0
zoom: 0
twelveHourFormat: false
coordinateFormat: ""
disabled: false
expirationTime: null
deviceLimit: -1
userLimit: 0
deviceReadonly: false
token: null
limitCommands: false
poiLayer: ""
password: null
__proto__: Object

For the WebSocket function is:

init.js:167 WebSocket connection to 'ws://MY_URL:8082/api/socket' failed: Error during WebSocket handshake: Unexpected response code: 500
get openWebsocket @ init.js:167
init.js:170 WebSocket closed
Andres Ramos4 years ago

Hello everyone

Did you find any solution for this?

Ivan Mudryj3 years ago

Nop

macelo2 years ago

Any suggestion, I am trying to consume websocket api in ANGULAR