proxyman-windows-linux icon indicating copy to clipboard operation
proxyman-windows-linux copied to clipboard

[BUG] Map remote websocket support

Open mariusvn opened this issue 1 year ago • 23 comments

Description

Does the map remote tool supports websockets on windows ?

mariusvn avatar Apr 02 '24 10:04 mariusvn

Yes it does 👍🏻

kics223w1 avatar Apr 02 '24 10:04 kics223w1

jeez that was fast,

is there anthing special to do because i struggle with that.

Proxyman_PGe2BVHx6L

The link is hidden as it is owned by clients

mariusvn avatar Apr 02 '24 10:04 mariusvn

on the image the websocket ignore the map remote here

mariusvn avatar Apr 02 '24 10:04 mariusvn

Proxyman_ZrA0U4NcDb

it is still on the original url (yes it is the same url as the blurred part on the previous image)

mariusvn avatar Apr 02 '24 10:04 mariusvn

@kics223w1 please investigate it. Try to Map Remote from WSS (production) to a local WS.

@mariusvn In the Rule text fields, can you try to remove the wss:// prefix part, it should be my-domain.fr and try again? 🤔

May I also ask what Proxyman Windows version you're using?

NghiaTranUIT avatar Apr 02 '24 10:04 NghiaTranUIT

Okay, I'll investigate this issue.

kics223w1 avatar Apr 02 '24 11:04 kics223w1

on the image the websocket ignore the map remote here

If you would, can you click on the Summary Tab -> expand the Debugging Tool node -> Verify there is the Map Remote information 🤔 .

If there is, it means the MapRemote Tool has failed to map your request.

If there is nothing, it means the request doesn't match the MapRemote Tool. Please delete the rule and right click on the request in the MainTable to create new rule.

For instance: image

kics223w1 avatar Apr 02 '24 11:04 kics223w1

i'll take a look in a few minutes, thanks for the active support btw

mariusvn avatar Apr 02 '24 11:04 mariusvn

So yeah i do have the map remote entry in the debugging tool section

Proxyman_sVAObkUqWH

mariusvn avatar Apr 02 '24 12:04 mariusvn

May I also ask what Proxyman Windows version you're using?

2.13.0

mariusvn avatar Apr 02 '24 12:04 mariusvn

In the Rule text fields, can you try to remove the wss:// prefix part, it should be my-domain.fr and try again? 🤔

same result :/

mariusvn avatar Apr 02 '24 12:04 mariusvn

Okay, I'm fixing this issue 👍🏻

kics223w1 avatar Apr 02 '24 12:04 kics223w1

Found the reason why this issue happened. @mariusvn

When Map Remote Tool started mapping the request, it will parse the origin URL to extract the hostname, port, scheme, etc...

For instance, when I map https://httpbin.proxyman.app/get to https://httpbin.org/get -> The tool will parse the https://httpbin.proxyman.app/get to get those above properties.

If it fails to parse the origin URL, the tool will ignore the request and do nothing.

May I ask, if your URL contains any invalid characters 🤔 (you don't need to provide the full URL)

If you don't mind, can you test your URL with the below code in https://playcode.io/typescript , I'm pretty sure the result will be false.

const isValidURL = (url: string): boolean => {
  try {
    new URL(url);
    return true;
  } catch (e) {
    return false;
  }
};

const yourURL = "https://github.com";

console.log(isValidURL(yourURL));

kics223w1 avatar Apr 03 '24 18:04 kics223w1

@kics223w1 The URL is likely valid because modern network clients always construct valid URLs.

NghiaTranUIT avatar Apr 04 '24 13:04 NghiaTranUIT

@mariusvn if you don't mind, please use this Beta build: https://download.proxyman.io/beta/Proxyman+Setup+2.13.0_Fix_Map_Remote_Websocket.exe

and share with me your result 👍

Screenshots

Screenshot 2024-04-05 at 09 31 37

NghiaTranUIT avatar Apr 05 '24 05:04 NghiaTranUIT

i will try this afternoon 👍

mariusvn avatar Apr 05 '24 09:04 mariusvn

If you don't mind, can you test your URL with the below code in https://playcode.io/typescript , I'm pretty sure the result will be false.

It does returns true.


May I ask, if your URL contains any invalid characters 🤔 (you don't need to provide the full URL)

x are alphabetic characters [a-z]

wss://xxx-xxxxx-xxx.xxxxxx.fr/ng-cli-ws


@mariusvn if you don't mind, please use this Beta build and share with me your result 👍

So I tried even without the wss:// prefix and it did not work.

it detects that the map remote should apply but mark - as note and do not map it.

it does works perfectly for http. In fact, I am using the map remote tool to simulate that my angular dev server is located on another domain, which works perferctly. (yes this is weird but my clients have a weird setup x) )

I noticed the issue when i wanted to make the live reload work.

it looks like its only with other protocols than http.

mariusvn avatar Apr 05 '24 13:04 mariusvn

@mariusvn May I ask, did you enable Allow List, Block List or Network Conditions Tool while working with Map Remote and Websocket 🤔

If you are enabling the Allow List with Map Remote, please turn off the Allow List. There is a bug about Allow List + Map Remote + Websocket.

kics223w1 avatar Apr 07 '24 07:04 kics223w1

Yep that's it !!

Is it possible to add script before or after the map remote step ? because i need to update the origin header to make it work

mariusvn avatar Apr 08 '24 08:04 mariusvn

  • @mariusvn Currently, Scripting doesn't support WebSocket yet.

  • May I ask, did you need to set the origin header equal the host in Map Remote Editor to make your WebSocket request work, right 🤔

  • I can refactor the code in Map Remote to do that, no need to use Scripting.

  • P/S: For HTTP and HTTPS, Scripting executes request after Map Remote.

kics223w1 avatar Apr 08 '24 08:04 kics223w1

May I ask, did you need to set the origin header equal the host in Map Remote Editor to make your WebSocket request work, right 🤔

Yes that's exactly that

I can refactor the code in Map Remote to do that, no need to use Scripting.

That would be nice but its not super urgent so no worries if i dont have it real soon

P/S: For HTTP and HTTPS, Scripting executes request after Map Remote.

Noted ! 👍

mariusvn avatar Apr 09 '24 08:04 mariusvn

Yes that's exactly that

Okay, I'll refactor the code 👍🏻

kics223w1 avatar Apr 09 '24 08:04 kics223w1

@mariusvn
The new release 2.14.0 contains the fixed, please give it a try when you get a chance 🚀

Allow List's now working with Map Remote as usual, you don't need to turn off Allow List when using Map Remote Tool.

I also refactored the code in Map Remote Tool to update the origin header 👍🏻

kics223w1 avatar Apr 15 '24 12:04 kics223w1