Attempt websocket fix
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
mud.iamtalon.me {
|
mud.iamtalon.me {
|
||||||
|
# For all WebSocket requests to /mud-ws, proxy to the WebSocket server on port 3001
|
||||||
|
@websocket {
|
||||||
|
path /mud-ws*
|
||||||
|
}
|
||||||
|
reverse_proxy @websocket svelte-mud:3001
|
||||||
|
|
||||||
|
# For all other requests, proxy to the SvelteKit app on port 3000
|
||||||
reverse_proxy svelte-mud:3000
|
reverse_proxy svelte-mud:3000
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ services:
|
|||||||
- revproxy
|
- revproxy
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
|
# No need to publish ports to host, but expose them to container network
|
||||||
|
expose:
|
||||||
|
- 3000
|
||||||
|
- 3001
|
||||||
|
|
||||||
# Define networks to connect to external services
|
# Define networks to connect to external services
|
||||||
networks:
|
networks:
|
||||||
|
|||||||
@@ -51,14 +51,21 @@ export class MudConnection extends EventEmitter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Connect through the standalone WebSocket server on port 3001
|
// Determine the WebSocket URL based on environment
|
||||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
|
||||||
const wsHost = `${window.location.hostname}:3001`;
|
let wsUrl;
|
||||||
|
|
||||||
const url = `${wsProtocol}://${wsHost}/mud-ws?host=${encodeURIComponent(this.host)}&port=${this.port}&useSSL=${this.useSSL}`;
|
// In development, use port 3001
|
||||||
console.log('Connecting to WebSocket server:', url);
|
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
|
||||||
|
wsUrl = `${wsProtocol}://${window.location.hostname}:3001/mud-ws?host=${encodeURIComponent(this.host)}&port=${this.port}&useSSL=${this.useSSL}`;
|
||||||
|
} else {
|
||||||
|
// In production, use the same domain & port as the web app
|
||||||
|
wsUrl = `${wsProtocol}://${window.location.host}/mud-ws?host=${encodeURIComponent(this.host)}&port=${this.port}&useSSL=${this.useSSL}`;
|
||||||
|
}
|
||||||
|
|
||||||
this.webSocket = new WebSocket(url);
|
console.log('Connecting to WebSocket server:', wsUrl);
|
||||||
|
|
||||||
|
this.webSocket = new WebSocket(wsUrl);
|
||||||
|
|
||||||
this.webSocket.binaryType = 'arraybuffer';
|
this.webSocket.binaryType = 'arraybuffer';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user