plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.16k stars 175 forks source link

Question: How to setup networking with doppio in browser? #442

Closed hrj closed 8 years ago

hrj commented 8 years ago

I have read through this wiki page and through src/natives/java_net.ts, but I am not fully certain how this works.

The image on the wiki page is not loading, which may have held some clues.

If I understand right, whenever a socket connection to host:port is requested from Java land, that gets converted to a ws://host:port request. Hence, if I need to connect to xyz.com:80 via HttpURLConnection, I will need to first run a websocket server (websockify) on xyz.com:80.

Alternatively, I could run websockify on my own host and configure the http proxy in Java Land to point to this, so that all http requests get routed to my host, and then proxied to the final destination.

Is the above right?

Thanks!

jvilk commented 8 years ago

If I understand right, whenever a socket connection to host:port is requested from Java land, that gets converted to a ws://host:port request. Hence, if I need to connect to xyz.com:80 via HttpURLConnection, I will need to first run a websocket server (websockify) on xyz.com:80.

Yup, you got it right.

Alternatively, I could run websockify on my own host and configure the http proxy in Java Land to point to this, so that all http requests get routed to my host, and then proxied to the final destination.

We haven't implemented it that way, but yes, this is possible.

The current networking code needs to be tested/cleaned up/updated to use the latest websockify. I admit that I have let it languish for the past couple of years, mainly because I never set up automated testing with websockify. Once we have automated tests that fail, it should not be too difficult to fix the implementation.

hrj commented 8 years ago

Thanks for the detailed response, as always! :+1:

jvilk commented 8 years ago

Here are actual instructions from our 2014 demo. That's how it is supposed to work.

EDIT: The "bug" mentioned on that page was my own confusion; that native call is supposed to be blocking, and we were just returning 0 when no data was ready.