Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File streaming broken with socket.io polling #14067

Closed
ramymagdy opened this issue Aug 23, 2024 · 6 comments · Fixed by #14659
Closed

File streaming broken with socket.io polling #14067

ramymagdy opened this issue Aug 23, 2024 · 6 comments · Fixed by #14659
Milestone

Comments

@ramymagdy
Copy link

ramymagdy commented Aug 23, 2024

Bug Description:

We have to run Theia through a proxy that doesn't support the Connection "Upgrade" for websocket. So instead we need to rely on socket.io long polling.

With the socket.io connection polling the File Explorer act's randomly and no files are opened in the editor ( regardless of the file type )
I have to go randomly clicking through files till I get one of the opening,

theia

Steps to Reproduce:

Apply the following patch

diff --git a/packages/core/src/browser/messaging/ws-connection-source.ts b/packages/core/src/browser/messaging/ws-connection-source.ts
index 24d7d7920..5d4a60a37 100644
--- a/packages/core/src/browser/messaging/ws-connection-source.ts
+++ b/packages/core/src/browser/messaging/ws-connection-source.ts
@@ -202,6 +202,7 @@ export class WebSocketConnectionSource implements ConnectionSource {
     protected createWebSocket(url: string): Socket {
         return io(url, {
             path: this.createSocketIoPath(url),
+           transports: ["polling"],
             reconnection: true,
             reconnectionDelay: 1000,
             reconnectionDelayMax: 10000,
diff --git a/packages/core/src/node/messaging/websocket-endpoint.ts b/packages/core/src/node/messaging/websocket-endpoint.ts
index 187603c77..f98e50ce7 100644
--- a/packages/core/src/node/messaging/websocket-endpoint.ts
+++ b/packages/core/src/node/messaging/websocket-endpoint.ts
@@ -42,6 +42,7 @@ export class WebsocketEndpoint implements BackendApplicationContribution {
 
     onStart(server: http.Server | https.Server): void {
         const socketServer = new Server(server, {
+           transports: ["polling"],
             pingInterval: this.checkAliveTimeout,
             pingTimeout: this.checkAliveTimeout * 2,
             maxHttpBufferSize: this.maxHttpBufferSize

Or else you may use the following haproxy configurations that will just deny any request with "Upgrade" header.


global
	log /dev/log	local0
	log /dev/log	local1 notice
	chroot /var/lib/haproxy
	stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
	stats timeout 30s
	user haproxy
	group haproxy
	daemon

	# Default SSL material locations
	ca-base /etc/ssl/certs
	crt-base /etc/ssl/private

	# See: https://ssl-config.mozilla.org/#server=haproxy&server-version=2.0.3&config=intermediate
        ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
        ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
        ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

defaults
	log	global
	mode	http
	option	httplog
	option	dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000
	errorfile 400 /etc/haproxy/errors/400.http
	errorfile 403 /etc/haproxy/errors/403.http
	errorfile 408 /etc/haproxy/errors/408.http
	errorfile 500 /etc/haproxy/errors/500.http
	errorfile 502 /etc/haproxy/errors/502.http
	errorfile 503 /etc/haproxy/errors/503.http
	errorfile 504 /etc/haproxy/errors/504.http

frontend main_test

    bind 0.0.0.0:4000

    # ACL to detect WebSocket connection based on Upgrade header
    acl is_websocket hdr(Upgrade) -i websocket

    # Block WebSocket connections with a 403 Forbidden error
    http-request deny if is_websocket

    default_backend             test

backend test
   balance roundrobin

   server server1 localhost:31852

Additional Information

  • Operating System: Linux/Windows
  • Theia Version: Git HEAD
@tsmaeder
Copy link
Contributor

@msujew I think you worked on the socket-io infra, right? Any comments off the top of your head?

@msujew
Copy link
Member

msujew commented Sep 19, 2024

Sorry for the late response, but I don't have any clue without digging deeper into this: The HTTP fallback should handle the exact same requests/responses as the websocket backend. Unless the connection is literally dropping responses (which it shouldn't, since it's HTTP) I have no idea why this happens.

I'll try to reproduce this once I'm back from vacation.

@splattner
Copy link

any chance you looked into this? I'm experience the same problem. When websockets are disabled, I cannot open any file.

@msujew
Copy link
Member

msujew commented Dec 15, 2024

Fell off the plate - looking into this tomorrow :)

@msujew
Copy link
Member

msujew commented Dec 20, 2024

I was able to reproduce this. Note that the explorer itself works. It's the file streaming that doesn't work. It seems specific to streaming, normal file loading works as expected. I'm already on vacation but I'll get back to this after the start of the new year.

@msujew msujew changed the title Explorer broken with socket.io polling File streaming broken with socket.io polling Dec 20, 2024
@msujew
Copy link
Member

msujew commented Dec 20, 2024

I actually found the issue fairly quickly, so I just fixed it. See #14659.

@jfaltermeier jfaltermeier added this to the 1.58.0 milestone Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants