angular-websocket icon indicating copy to clipboard operation
angular-websocket copied to clipboard

URL is not valid

Open amrdruid opened this issue 9 years ago • 7 comments

Why it gives me invalid url ?

I tried this :

var dataStream = $websocket('ws:://localhost:3000/api/students/testing');

and this :

var dataStream = $websocket('ws:://api/students/testing');

but it is no use

amrdruid avatar Feb 11 '16 21:02 amrdruid

Now i'm in a different state

I changed my code to var dataStream = $websocket('ws://127.0.0.1:3030');

and it give me : WebSocket connection to 'wss://127.0.0.1:3030/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

Here is my grunt file :

  // Define the configuration for all the tasks
  grunt.initConfig({
    // Project settings

    websocket: {
       options: {
         port: 3030,
         handler: 'websockets/websocketHandler.js'

       },
       target: {}
     },

amrdruid avatar Feb 11 '16 22:02 amrdruid

This is the latest error :

WebSocket connection to 'ws://localhost:3000/api/students/testing' failed: Error during WebSocket handshake: Unexpected response code: 200

Code :

var dataStream = $websocket('ws://localhost:3000/api/students/testing');

amrdruid avatar Feb 11 '16 22:02 amrdruid

I have met ths same question,while connect to nodejs server written by sockjs.

//Mock websocket apis
var echo = sockjs.createServer({sockjs_url: 'http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js' });
echo.on('connection', function(conn){
    console.log("sock is conn");
    conn.on('data', function(message){
        conn.write("already recived");
    });
    conn.on('close', function() {});
});
var server = http.createServer(app);
echo.installHandlers(server, {prefix: '/echo'});
server.listen(18081);

And in my angular project, JS as follows

var dataStream = $websocket('ws://localhost:18081/echo'); dataStream.onMessage(function(message){
      console.log(message);
 });

And I got the error

WebSocket connection to 'ws://localhost:18081/echo' failed: Error during WebSocket handshake: Unexpected response code: 200

Measy avatar May 25 '16 01:05 Measy

I have seem the

TODO: Add SockJS support

is the reason that "Error in connection establishment" while connect to the nodejs server writen in sockjs?

Measy avatar May 25 '16 02:05 Measy

same problem here. Any update on this ?

RilRil avatar Jul 22 '16 12:07 RilRil

Are you able to connect to the WS endpoint with a different tool?

el-chogo avatar Oct 21 '16 07:10 el-chogo

Same issue. Any solution here?

Muneem avatar Feb 16 '17 17:02 Muneem