fastly / pushpin

A proxy server for adding push to your API, used at the core of Fastly's Fanout service
https://pushpin.org
Apache License 2.0
3.66k stars 153 forks source link

Not able to publish messages via 0MQ from backend server #47705

Open shreyasdn opened 2 years ago

shreyasdn commented 2 years ago

I have a setup where i have a docker image running the pushpin server and have used configuration from the sample file to configure the server. I am able to get and send messages via http but i am unable to publish back messages to the 0MQ SUB socket. Does the SUB socket also require routes file to have a 0MQ line? Can http and 0MQ be used together i.e. get message to backend via http and send message back to pushpin via 0MQ? I have posted the config used below. Also on the pushpin side i am unable to check if the message from the socket has reached, I have turned on the debug mode but am not able to see any activity.

[global]
include={libdir}/internal.conf
[runner]
services=condure,zurl,pushpin-proxy,pushpin-handler
http_port=7999
[proxy]
sig_key=value_is_present
debug=true
# routes config file (path relative to location of this file)
routesfile=routes
# enable debug mode to get informative error responses
debug=false
# whether to use automatic CORS and JSON-P wrapping
auto_cross_origin=false
[handler]
# ipc permissions (octal)
#ipc_file_mode=777

# bind PULL for receiving publish commands
push_in_spec=tcp://*:5560

# list of bind SUB for receiving published messages
push_in_sub_spec=tcp://0.0.0.0:5562

# whether the above SUB socket should connect instead of bind
push_in_sub_connect=false

# addr/port to listen on for receiving publish commands via HTTP
push_in_http_addr=0.0.0.0
push_in_http_port=5561
jkarneges commented 2 years ago

Hi,

The SUB socket is tricky. Nothing will show up in the Pushpin logs unless there is at least one subscribing client. You also need to be careful about the general race condition with ZeroMQ PUB/SUB, which happens if you send too soon after connecting the SUB socket and you've not yet received subscriptions. For example, if you make a simple program that connects to Pushpin and immediately sends a message, it will likely be dropped. The SUB socket is better used by long-running programs. For short-running programs, you should publish via HTTP. If you just want to test sending to Pushpin's SUB socket from a short-running program, try inserting a delay after connecting but before sending a message.

There's no need to do anything with the routes. You can have requests routed to an HTTP backend and still publish via ZeroMQ.

shreyasdn commented 2 years ago

Hi, Thanks for the answer i am providing a 3 seconds delay to the PUB socket but still no success. Also just so that i have understood correctly the pushpin server itself subscribes for updates to any channel it send out right?

jkarneges commented 2 years ago

That's correct. You could try using https://github.com/fanout/pushpin/blob/master/tools/monitorsubsock.py (requires python 2 and pyzmq) to inspect the subscribes/unsubscribes.

PankhudiB commented 1 year ago

Hello @shreyasdn @jkarneges

I am facing similar problem. Did it work for you ? Any resolution ?