ProxymanApp / proxyman-windows-linux

Public tracker for Proxyman Windows/Linux
https://proxyman.io/
MIT License
114 stars 4 forks source link

[BUG] Map remote websocket support #396

Open mariusvn opened 8 months ago

mariusvn commented 8 months ago

Description

Does the map remote tool supports websockets on windows ?

kics223w1 commented 8 months ago

Yes it does 👍🏻

mariusvn commented 8 months ago

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 commented 8 months ago

on the image the websocket ignore the map remote here

mariusvn commented 8 months ago

Proxyman_ZrA0U4NcDb

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

NghiaTranUIT commented 8 months ago

@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?

kics223w1 commented 8 months ago

Okay, I'll investigate this issue.

kics223w1 commented 8 months ago

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
mariusvn commented 8 months ago

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

mariusvn commented 8 months ago

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

Proxyman_sVAObkUqWH

mariusvn commented 8 months ago

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

2.13.0

mariusvn commented 8 months ago

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 :/

kics223w1 commented 8 months ago

Okay, I'm fixing this issue 👍🏻

kics223w1 commented 8 months ago

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));
NghiaTranUIT commented 8 months ago

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

NghiaTranUIT commented 8 months ago

@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

mariusvn commented 8 months ago

i will try this afternoon 👍

mariusvn commented 8 months ago

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.

kics223w1 commented 8 months ago

@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.

mariusvn commented 7 months ago

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

kics223w1 commented 7 months ago
mariusvn commented 7 months ago

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 ! 👍

kics223w1 commented 7 months ago

Yes that's exactly that

Okay, I'll refactor the code 👍🏻

kics223w1 commented 7 months ago

@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 👍🏻