moll / node-mitm

Intercept and mock outgoing Node.js network TCP connections and HTTP requests for testing. Intercepts and gives you a Net.Socket, Http.IncomingMessage and Http.ServerResponse to test and respond with. Super useful when testing code that hits remote servers.
Other
641 stars 48 forks source link

Question - pipes #47

Closed wibobm closed 5 years ago

wibobm commented 6 years ago

I have not been successful in both reading and writing to a mitm socket using pipe() within the same connection. I can do one or the other but not both. When trying to do both the data streaming into the mtm socket comes through just fine but the data being streamed back is never sent back to the client. Any tips or reasons for this behavior?

For example, the following would just hang:

socket.pipe(augmentThisData).pipe(socket);

Thanks.

moll commented 6 years ago

Hi! Let me take a look. What version of Node are you using for this?

wibobm commented 6 years ago

v9.3.0

moll commented 6 years ago

I gave it a try and added https://github.com/moll/node-mitm/commit/6260cf49c31eb10739eaba25d300ffebbbfe4031 to test it. It seems to work without any changes. Would you mind running Mitm.js's tests or copy-pasting that particular Upcase transformer to your own code to see if at least the basics work for you?

That pipe of yours must be doing something tricker than Must can handle, so we'd need to look into it in more detail to find out what. Is that a plain TCP socket or a secure one?

wibobm commented 6 years ago

Will do! My pipes are binary but nothing special. I'll give it whirl and get back to you.

moll commented 6 years ago

Made any progres, @wibobm?

moll commented 5 years ago

I'll close this issue for now. If it's still a problem, please write back @wibobm.