MeshCentral icon indicating copy to clipboard operation
MeshCentral copied to clipboard

Unable to connect websocket on Iframe

Open rajatheynetech opened this issue 2 years ago • 16 comments

Remote desktop embedding on iframe shows "Unable to connect to WebSocket -- reconnect". But the same URL on iframe src is working perfectly on the browser.

Iframe screen Screenshot 2022-08-29 at 2 25 05 PM

rajatheynetech avatar Aug 29 '22 09:08 rajatheynetech

Can you open your browser's console and show any errors?

Also, did you put:

"allowframing": true

In the settings section of your config.json?

Ylianst avatar Aug 29 '22 16:08 Ylianst

@Ylianst i believe the user did #4461

si458 avatar Aug 29 '22 17:08 si458

Can you open your browser's console and show any errors?

Also, did you put:

"allowframing": true

In the settings section of your config.json?

Yes i did

rajatheynetech avatar Aug 30 '22 09:08 rajatheynetech

Screenshot 2022-08-30 at 2 44 07 PM

rajatheynetech avatar Aug 30 '22 09:08 rajatheynetech

@Ylianst i believe the user did #4461

This issue was raised by me. And the current issue is not with the iframe. The URL loaded in the iframe shows an error like WebSocket couldn't connect.

rajathdeskday avatar Sep 02 '22 09:09 rajathdeskday

@Ylianst @si458 , Is there a fix for this problem? A 404 error is returned by the commander.ashx while trying to embed in an iframe. However, there is no problem when using the same url directly in the browser.

sufailDesk avatar Sep 14 '22 07:09 sufailDesk

@rajatheynetech ...you're trying to connect to 127.0.0.1 instead of the dns name, so you're going to have SSL negotiation problems.

SSL requires the right names in the certs in the browser.

silversword411 avatar Sep 14 '22 14:09 silversword411

No, it is connecting to htpps://domain.com/commander.ashx

sufailDesk avatar Sep 14 '22 16:09 sufailDesk

What is commander.ashx ? What are you expecting? Never heard of that before.

On mine all I get is a connect button, and a disconnected message. It's a status 304...which makes me think invalid resource.

Commander was the old v1 version of Mesh I believe, before the websockets rewrite.

silversword411 avatar Sep 14 '22 17:09 silversword411

Like I mentioned above the problem is only for remote connecting through embedding into an iframe. Embedding is done through by following only meshcentral's user guide. No issue when the same url directly applied into the browser.

sufailDesk avatar Sep 15 '22 04:09 sufailDesk

I understand you're trying to use an iframe and embed it in your app. This is your user guide's instructions right?

https://ylianst.github.io/MeshCentral/meshcentral/#embedding-meshcentral

I see no references to any "commander.ashx" What is that? I only see commander.htm in MeshCentral's source code: https://github.com/Ylianst/MeshCentral/blob/master/public/commander.htm

Your error is also about FLoC (which is dead and being removed from chrome), so you must be in a special dev mode to even see that error. https://www.drupal.org/project/drupal/issues/3284706

Your problem is probably completely unrelated to the error you posted.

silversword411 avatar Sep 15 '22 14:09 silversword411

Maybe you can glean something from Tactical RMM's source on how to integrate MeshCentral via iframe...working well there:

https://github.com/amidaware/tacticalrmm https://github.com/amidaware/tacticalrmm-web

silversword411 avatar Sep 15 '22 14:09 silversword411

@Ylianst @rajatheynetech did you get resolution of this error while running MeshCentral in Iframe?

dkapadiaatlivewire avatar Sep 20 '22 07:09 dkapadiaatlivewire

@Ylianst @rajatheynetech did you get resolution of this error while running MeshCentral in Iframe?

No. Still not work for iframe. but we have not tried the latest solutions which mentioned above.

sufailDesk avatar Sep 20 '22 11:09 sufailDesk

@silversword411 I am facing the same issue in iframe when I am trying to connect to MeshCentral URL with login token .Without login token it is working fine it is displaying login page of meshcentral

bindulu05 avatar Nov 16 '22 19:11 bindulu05

Remote desktop embedding on iframe shows "Unable to connect to WebSocket -- reconnect". But the same URL on iframe src is working perfectly on the browser.

Iframe screen Screenshot 2022-08-29 at 2 25 05 PM

I encountered the same problem and finally found that the error was caused by cross-site request. I solved this problem by setting the "sessionSameSite": "None" configuration item in config.json. Refer to the following issue: Meshcentral not loading in iFrame in Chrome or Edge | Missing SameSite Attribute on Cookie #4211.

King-tu avatar Jul 09 '24 03:07 King-tu