websockets / ws

Simple to use, blazing fast and thoroughly tested WebSocket client and server for Node.js
MIT License
21.68k stars 2.42k forks source link

Error during WebSocket handshake: #1431

Closed paragsahu closed 6 years ago

paragsahu commented 6 years ago

I try to publishing message to subscriber to the topic but unable to establish connection getting error please help screenshot from 2018-08-17 17-56-06 me

this is my .ts file

import { Component, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import "rxjs/Rx"; import {ChatRoom} from './ChatRoom.model'; import {Paho} from 'ng2-mqtt/mqttws31';

@Component({ selector: 'app-chat-window', templateUrl: './chat-window.component.html', styleUrls: ['./chat-window.component.css'] }) export class ChatWindowComponent implements OnInit { msg:any; showMessage:any; // chatRoom:ChatRoom={topic_Id:'',startTime:'',endTime:'',customer_Id:'',customerCare_Id:''}; chatRoom:any; client;

constructor(private http: HttpClient) { this.client = new Paho.MQTT.Client('localhost', 1883, 'qwerty12345');

this.onMessage();
this.onConnectionLost();
this.client.connect({onSuccess: this.onConnected.bind(this)});

}

searchValue:string = '';

ngOnInit() {

}

onConnected() { console.log("Connected"); this.client.subscribe("123456"); this.sendMessage('HelloWorld'); /onSuccess: onConnect, useSSL: true;/ }

sendMessage(message: string) { let packet = new Paho.MQTT.Message(message); packet.destinationName = "123456"; this.client.send(packet); }

onMessage() { this.client.onMessageArrived = (message: Paho.MQTT.Message) => { console.log('Message arrived : ' + message.payloadString); }; }

onConnectionLost() { this.client.onConnectionLost = (responseObject: Object) => { console.log('Connection lost : ' + JSON.stringify(responseObject)); }; }

createChatRoom(){ this.http.get('http://localhost:8080/api/create-chatroom') .subscribe(data=>{ this.chatRoom=data this.http.get('http://localhost:8080/api/subscribe-message/' + '5b7551de1fc582297d78bf0a') .subscribe(data=>{data
}); }); }

publishMessage(topic) { console.log(this.msg); this.http.get('http://localhost:8080/api/publish-message/' + topic + "/" + this.msg) .subscribe(data=>{ }); // this.showMessage=this.msg; // this.msg=''; }

}

lpinca commented 6 years ago

Please try to reproduce the issue without any wrapping modules, only ws. This issue tracker is for ws only.

lpinca commented 6 years ago

Closing due to inactivity.