unable to get server data in ngx-socket-io
See original GitHub issueHi, I wood like to request you to please help to solve this problem. i am using ngx-socket-io repository , angular 6. i am connect to the server but i am unable to get the data from the server. my code is
app.module.ts
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
const config: SocketIoConfig = { url: 'http://af098cb1.ngrok.io', options: {} };
imports: [
SocketIoModule.forRoot(config),
}
socket.services.ts
constructor(private socket: Socket) {
}
getMessage() {
return this.socket
.fromEvent<any>("sendchat")
.map(data => data.msg);
}
getData(){
console.log("-----------");
this.socket.on('sendchat', function (socket) {
console.log('User data', socket);
});
}
Output:
it prints this ---------------------- but can not get the user data and response.and also i not get the single error message i cont understand whats going on please help out.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
node.js - ngx-socket-io cannot connect to server because of ...
There (https://socket.io/docs/v3/migrating-from-2-x-to-3-0/index.html) I found that issue may be solved by setting allowEIO3: true , but it didn ...
Read more >Troubleshooting connection issues | Socket.IO
IO server may encounter a temporary failure or be restarted; the server itself may be killed as part of an autoscaling policy ...
Read more >ngx-socket-io - npm
We need to configure SocketIoModule module using the object config of type SocketIoConfig , this object accepts two optional properties they are ...
Read more >How To Create a Real-Time App with Socket.IO, Angular, and ...
How To Create a Real-Time App with Socket.IO, Angular, and Node.js · Step 1 — Setting Up the Project Directory and Creating the...
Read more >Socket.IO - Error Handling - Tutorialspoint
Socket.IO - Error Handling, We have worked on local servers until now, which will almost never give us errors related to connections, timeouts,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You need to subscribe to the event getData
SocketServices.ts
Then in your component class
Home.ts
salute.
We have to use subscribe