Getting 404 error with @nestjs/websockets
See original GitHub issueServer :
import {
ConnectedSocket,
MessageBody,
OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit,
SubscribeMessage,
WebSocketGateway,
WebSocketServer
} from '@nestjs/websockets';
import { Server, Socket } from 'socket.io';
import { Logger } from '@nestjs/common';
@WebSocketGateway()
export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect {
@WebSocketServer()
server: Server;
private logger: Logger = new Logger('AppGateway');
@SubscribeMessage('msgToServer')
handleMessage(client: Socket, payload: string): void {
this.server.emit('msgToClient', payload);
}
afterInit(server: Server) {
this.logger.log('Init');
}
handleDisconnect(client: Socket) {
this.logger.log(`Client disconnected: ${client.id}`);
}
handleConnection(client: Socket, ...args: any[]) {
this.logger.log(`Client connected: ${client.id}`);
}
}
Client side:
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
const socketConfig: SocketIoConfig = {
url: 'http://localhost:3000',
options: {
path: '/'
}
};
Error
GET http://localhost:3000/?EIO=4&transport=polling&t=NhD2AKw 404 (Not Found)
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:7
Top Results From Across the Web
WebSocket connection failed errors after upgrade to Next.js 12
js 12, I'm getting the following error while running the app in dev mode: WebSocket connection to 'wss://app.name.dev/_next/webpack-hmr' failed:.
Read more >Next.js default 404 page is not shown for non-existing pages
I'm creating a next.js app. And when I enter a non-existing URL, instead of seeing the default 404 page, I see this message:....
Read more >Javascript console full of WebSocket errors with HTTP code ...
However, the problem has only been solved partially. Now the response code turned from 404 into 405 “method not allowed”. :frowning:.
Read more >Dynamic Routes Details - Next.js
The paths that have not been generated at build time will not result in a 404 page. Instead, Next.js will serve a “fallback”...
Read more >Socket.io client connect 404 not found on Netlify - Support
i have this problem to. i'm using nextjs and my chatbox works in local machine but when i deployed it on netlify i...
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
Guys, make sure you’re hitting your nestjs server. If you use angular you might want to configure proxy like that:
Same error mine works in dev but not in production.