BCDA-APS / qs-web2023

Web client for Bluesky queueserver using ReactJS
Other
2 stars 0 forks source link

How to connect by 0MQ from a web client? #4

Closed prjemian closed 1 year ago

prjemian commented 1 year ago

How to connect (to the queueserver) by 0MQ from a web client?

Originally posted by @prjemian in https://github.com/BCDA-APS/qs-web2023/issues/3#issuecomment-1574000928

prjemian commented 1 year ago

https://duckduckgo.com/?q=how+to+connect+to+a+server+by+ZMQ+from+a+web+client%3F&t=brave&ia=web

prjemian commented 1 year ago

Perhaps this comment in the SO post is relevant?

Browsers don't allow Raw socket connections, but Websocket ones.

And that might be the reason why the bluesky-webclient repo uses an intermediate web server. A very important thing to note in the documentation.

prjemian commented 1 year ago

That's exactly the problem and the reason for the bluesky httpserver project.

See this figure I just created: image

The existing clients (command-line qserver application, the queueserver-monitor GUI, and Python code itself) all commiunicate with the QS (queueserver) using ZMQ. By design, the web client is much more restricted in the network technology it can use, to prevent misuse by a bad web client. The web client is restricted to http communications and that is why the QS Web Server (aka the bluesky-httpserver project) is inserted. It converts between http and JSON over ZMQ.

prjemian commented 1 year ago

And, since the bluesky-httpserver expects a kafka server, we should add this to our system as well.

prjemian commented 1 year ago

We'll need to add a QS Web Server, such as the bluesky-httpserver project, to be able to build the QS Web Client. See this revision to the above figure: image

prjemian commented 1 year ago

So, to answer the original question:

How to connect by 0MQ from a web client?

The answer is: You don't.

Instead, you insert an adapter which converts between the http protocol required for the web client and the local protocol (ZMQ) used by the QS.