Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/events URL returns no content in 0.31.0 #1024

Open
pfhayes opened this issue Feb 19, 2020 · 20 comments
Open

/events URL returns no content in 0.31.0 #1024

pfhayes opened this issue Feb 19, 2020 · 20 comments

Comments

@pfhayes
Copy link
Contributor

pfhayes commented Feb 19, 2020

We have just upgraded to 0.31.0 from 0.26.0 to pick up the recent GitHub API change.

The installation runs fine for several hours but then all requests will start timing out

It appears to be because an unbounded number of Pubsubstub connections are being created. I see many repeated events of the form

Feb 19 03:36:14 ip-172-31-37-230 env[1235]: I, [2020-02-19T03:36:14.855652 #1709]  INFO -- : [Pubsubstub::Subscription] Connecting client #7815470111917132360 (stack.1)

followed by an ever-growing number of repeated events of the form

Feb 19 03:39:19 ip-172-31-37-230 env[1235]: D, [2020-02-19T03:39:19.247287 #1728] DEBUG -- : [Pubsubstub::Subscription] Sending event #1582083559247 to client #7268750048476322816

This appears to be because the requests to /events?channels%5B%5D=stack.1 hang and return no content. In 0.26.0 the requests return content of the form:

id: 1582083655404
event: heartbeat
retry: 10000
data: ping

Reverting to 0.26.0 appears to fix the issue

Please let me know if I can provide any additional information to help diagnose the issue

@casperisfine
Copy link
Contributor

That's probably caused by the pubsubstub update, but it's been a while so I don't quite remember what we changed exactly.

Ideally, If you can, I recommend to run pubsubstub in it's own process as described here: #496 (comment) (it's really how it's meant to be used, the integrated form is for ease of use but isn't ideal at all).

Alternatively, it also has a degraded polling mode you can enable with: Pubsubstub.use_persistent_connections = false. Unless you have a lots of users, it should be more than enough.

I'd be happy to dig into this problem but, I wouldn't know where to start without a way to reproduce the problem, there is just so many moving parts it could be anything.

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 2, 2020

Thanks, I tried this and it does appear to be working better now

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 4, 2020

I spoke too soon, I'm still seeing the behaviour where the /events URL misbehaves even when running pubsubstub as a separate process

Pubsubstub.use_persistent_connections = false does appear to patch the problem

@casperisfine
Copy link
Contributor

That's weird. Cloud you post more logs?

I'd like to fix this issue if I can reproduce it.

Also I'm interested to know how you run pubsubstub externally. With puma? What version ? How many threads?

Any info you can provide is welcome.

@casperisfine
Copy link
Contributor

Also do you see any [Pubsubstub::Subscription] Disconnecting client ... in your logs?

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 4, 2020

Sure, here's my external proc setup, though the behaviour manifested the same as when it was set up with the defaults. let me know if I can provide anything else:

  • I don't see any "Disconnecting client..." messages in the logs
  • The "Connecting client" log messages appear whenever I curl /events, but I never get any response data

versions:

ruby 2.5.1-p57
puma Version 3.12.4

Procfile:

stream: bundle exec puma --config pubsubstub/puma_config.rb pubsubstub/config.ru --port 8000 --environment $RAILS_ENV
web:    bundle exec puma -p 3000 --environment $RAILS_ENV
worker: bundle exec sidekiq -C config/sidekiq.yml --environment $RAILS_ENV

pubsubstub/config.ru:

require 'rack'
require 'pubsubstub'

Pubsubstub.redis_url = 'redis://localhost:6379'
run Pubsubstub::StreamAction.new

pubsubstub/puma_config.rb

#!/usr/bin/env puma

# Tells puma to not wait on clients to sutdown
force_shutdown_after 0

# Number of processes
workers 2

# min, max threads per workers
threads 32, 256

output logs:

-- Logs begin at Tue 2020-03-03 14:07:56 UTC, end at Wed 2020-03-04 17:47:04 UTC. --
Started shipit.
started with pid 3820
started with pid 3821
started with pid 3823
[3822] Puma starting in cluster mode...
[3822] * Version 3.12.4 (ruby 2.5.1-p57), codename: Llamas in Pajamas
[3822] * Min threads: 32, max threads: 256
[3822] * Environment: production
[3822] * Process workers: 2
[3822] * Phased restart available
[3822] * Listening on tcp://0.0.0.0:8000
[3822] Use Ctrl-C to stop
[3822] - Worker 1 (pid: 3837) booted, phase: 0
[3824] Puma starting in cluster mode...
[3824] * Version 3.12.4 (ruby 2.5.1-p57), codename: Llamas in Pajamas
[3824] * Min threads: 8, max threads: 32
[3824] * Environment: production
[3824] * Process workers: 4
[3824] * Phased restart available
[3824] * Listening on tcp://0.0.0.0:3000
[3824] Use Ctrl-C to stop
[3822] - Worker 0 (pid: 3833) booted, phase: 0
[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.original_env` (called at /home/shipit/.rvm/gems/ruby-2.5.1/gems/shipit-engine-0.31.0/lib/shipit/command.rb:15)
[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.original_env` (called at /home/shipit/.rvm/gems/ruby-2.5.1/gems/shipit-engine-0.31.0/lib/shipit/command.rb:15)
[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.original_env` (called at /home/shipit/.rvm/gems/ruby-2.5.1/gems/shipit-engine-0.31.0/lib/shipit/command.rb:15)
[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.original_env` (called at /home/shipit/.rvm/gems/ruby-2.5.1/gems/shipit-engine-0.31.0/lib/shipit/command.rb:15)
[DEPRECATED] `Bundler.clean_env` has been deprecated in favor of `Bundler.unbundled_env`. If you instead want the environment before bundler was originally loaded, use `Bundler.original_env` (called at /home/shipit/.rvm/gems/ruby-2.5.1/gems/shipit-engine-0.31.0/lib/shipit/command.rb:15)
2020-03-04T17:40:59.416Z pid=3826 tid=go33rz1vq INFO: Booting Sidekiq 6.0.5 with redis options {:url=>"redis://127.0.0.1:6379/", :id=>"Sidekiq-server-PID-3826"}
2020-03-04T17:41:01.317Z pid=3826 tid=go33rz1vq INFO: Booted Rails 6.0.2.1 application in production environment
2020-03-04T17:41:01.317Z pid=3826 tid=go33rz1vq INFO: Running in ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
2020-03-04T17:41:01.317Z pid=3826 tid=go33rz1vq INFO: See LICENSE and the LGPL-3.0 for licensing details.
2020-03-04T17:41:01.317Z pid=3826 tid=go33rz1vq INFO: Upgrade to Sidekiq Pro for more features and support: http://sidekiq.org
[3824] - Worker 3 (pid: 3892) booted, phase: 0
[3824] - Worker 1 (pid: 3881) booted, phase: 0
[3824] - Worker 0 (pid: 3879) booted, phase: 0
[3824] - Worker 2 (pid: 3887) booted, phase: 0
I, [2020-03-04T17:42:10.442770 #3887]  INFO -- : [Pubsubstub::StreamAction] Starting subscriber
I, [2020-03-04T17:42:10.443615 #3887]  INFO -- : [Pubsubstub::Subscription] Connecting client #16755666861885495692 (default)
D, [2020-03-04T17:42:10.443753 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343730443 to client #16755666861885495692
I, [2020-03-04T17:42:10.443671 #3887]  INFO -- : [Pubsubstub::StreamAction] Starting heartbeat
I, [2020-03-04T17:42:10.444257 #3887]  INFO -- : [Pubsubstub::Subscriber] Subscribed to *.pubsub
D, [2020-03-04T17:42:25.443961 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343745443 to client #16755666861885495692
D, [2020-03-04T17:42:40.444067 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343760444 to client #16755666861885495692
I, [2020-03-04T17:42:54.507933 #3881]  INFO -- : [Pubsubstub::StreamAction] Starting subscriber
I, [2020-03-04T17:42:54.508518 #3881]  INFO -- : [Pubsubstub::Subscription] Connecting client #16503468300458047328 (default)
D, [2020-03-04T17:42:54.509293 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343774509 to client #16503468300458047328
I, [2020-03-04T17:42:54.508569 #3881]  INFO -- : [Pubsubstub::StreamAction] Starting heartbeat
I, [2020-03-04T17:42:54.509609 #3881]  INFO -- : [Pubsubstub::Subscriber] Subscribed to *.pubsub
D, [2020-03-04T17:42:55.444169 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343775444 to client #16755666861885495692
D, [2020-03-04T17:43:09.509541 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343789509 to client #16503468300458047328
D, [2020-03-04T17:43:10.444274 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343790444 to client #16755666861885495692
D, [2020-03-04T17:43:24.509652 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343804509 to client #16503468300458047328
D, [2020-03-04T17:43:25.444380 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343805444 to client #16755666861885495692
D, [2020-03-04T17:43:39.509761 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343819509 to client #16503468300458047328
D, [2020-03-04T17:43:40.444496 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343820444 to client #16755666861885495692
D, [2020-03-04T17:43:54.509870 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343834509 to client #16503468300458047328
D, [2020-03-04T17:43:55.444600 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343835444 to client #16755666861885495692
D, [2020-03-04T17:44:09.509983 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343849509 to client #16503468300458047328
D, [2020-03-04T17:44:10.444702 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343850444 to client #16755666861885495692
D, [2020-03-04T17:44:24.510093 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343864510 to client #16503468300458047328
D, [2020-03-04T17:44:25.444807 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343865444 to client #16755666861885495692
I, [2020-03-04T17:44:36.624611 #3887]  INFO -- : [Pubsubstub::Subscription] Connecting client #1468393434816319513 (default)
D, [2020-03-04T17:44:36.624680 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343876624 to client #1468393434816319513
D, [2020-03-04T17:44:39.510203 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343879510 to client #16503468300458047328
D, [2020-03-04T17:44:40.444942 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343880444 to client #1468393434816319513
D, [2020-03-04T17:44:40.445057 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343880444 to client #16755666861885495692
I, [2020-03-04T17:44:47.711825 #3881]  INFO -- : [Pubsubstub::Subscription] Connecting client #2094063602611329993 (default)
D, [2020-03-04T17:44:47.711897 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343887711 to client #2094063602611329993
D, [2020-03-04T17:44:54.510355 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343894510 to client #16503468300458047328
D, [2020-03-04T17:44:54.510430 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343894510 to client #2094063602611329993
D, [2020-03-04T17:44:55.445093 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343895444 to client #1468393434816319513
D, [2020-03-04T17:44:55.445033 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343895444 to client #16755666861885495692
D, [2020-03-04T17:45:09.510453 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343909510 to client #2094063602611329993
D, [2020-03-04T17:45:09.510533 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343909510 to client #16503468300458047328
D, [2020-03-04T17:45:10.445162 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343910445 to client #1468393434816319513
D, [2020-03-04T17:45:10.445239 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343910445 to client #16755666861885495692
D, [2020-03-04T17:45:24.510583 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343924510 to client #16503468300458047328
D, [2020-03-04T17:45:24.510661 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343924510 to client #2094063602611329993
D, [2020-03-04T17:45:25.445295 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343925445 to client #16755666861885495692
D, [2020-03-04T17:45:25.445367 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343925445 to client #1468393434816319513
D, [2020-03-04T17:45:39.510693 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343939510 to client #2094063602611329993
D, [2020-03-04T17:45:39.510791 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343939510 to client #16503468300458047328
D, [2020-03-04T17:45:40.445394 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343940445 to client #1468393434816319513
D, [2020-03-04T17:45:40.445496 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343940445 to client #16755666861885495692
D, [2020-03-04T17:45:54.510810 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343954510 to client #2094063602611329993
D, [2020-03-04T17:45:54.510940 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343954510 to client #16503468300458047328
D, [2020-03-04T17:45:55.445505 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343955445 to client #1468393434816319513
D, [2020-03-04T17:45:55.445581 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343955445 to client #16755666861885495692
D, [2020-03-04T17:46:09.510958 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343969510 to client #16503468300458047328
D, [2020-03-04T17:46:09.511030 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343969510 to client #2094063602611329993
D, [2020-03-04T17:46:10.445621 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343970445 to client #16755666861885495692
D, [2020-03-04T17:46:10.445716 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343970445 to client #1468393434816319513
D, [2020-03-04T17:46:24.511076 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343984510 to client #16503468300458047328
D, [2020-03-04T17:46:24.511150 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343984510 to client #2094063602611329993
D, [2020-03-04T17:46:25.445745 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343985445 to client #16755666861885495692
D, [2020-03-04T17:46:25.445822 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343985445 to client #1468393434816319513
D, [2020-03-04T17:46:39.511187 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343999511 to client #16503468300458047328
D, [2020-03-04T17:46:39.511261 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583343999511 to client #2094063602611329993
D, [2020-03-04T17:46:40.445840 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583344000445 to client #1468393434816319513
D, [2020-03-04T17:46:40.445915 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583344000445 to client #16755666861885495692
D, [2020-03-04T17:46:54.511305 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583344014511 to client #16503468300458047328
D, [2020-03-04T17:46:54.511387 #3881] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583344014511 to client #2094063602611329993
D, [2020-03-04T17:46:55.445961 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583344015445 to client #1468393434816319513
D, [2020-03-04T17:46:55.446040 #3887] DEBUG -- : [Pubsubstub::Subscription] Sending event #1583344015445 to client #16755666861885495692

@casperisfine
Copy link
Contributor

And do you have anything else between the client and the puma server? A reverse proxy maybe, e.g. nginx? If so how is it configured ?

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 4, 2020

Yes, we are using nginx. Here's our nginx conf, which is pretty vanilla

user www-data www-data;
worker_processes 1;

events {
    worker_connections 1024;
}

http {
    gzip on;
    gzip_min_length 1000;
    gzip_comp_level 4;
    gzip_vary on;

    server {
        listen 443 ssl;
        ssl_certificate      /etc/ssl/certs/shipit.crt;
        ssl_certificate_key  /etc/nginx/shipit.key;
        server_name ...;

        access_log  /var/log/nginx/access.log;
        error_log  /var/log/nginx/error.log;

        location / {
            proxy_pass         http://127.0.0.1:3000;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }

    server {
        listen 80;
        listen 8443 ssl;
        ssl_certificate      /etc/ssl/certs/shipit.crt;
        ssl_certificate_key  /etc/nginx/shipit.key;
        server_name ...;
        return 301 https://$server_name$request_uri;
    }
}

@casperisfine
Copy link
Contributor

I suspect the problem is caused by nginx buffering.

There's two way to confirm it:

  • You can set proxy_buffering off;
  • You can try to bypass nginx, e.g. with a curl request or something.

If that indeed solve the issues we can have pubsubstub respond with X-Accel-Buffering: no.

@casperisfine
Copy link
Contributor

Hum, actually we already handle that: https://github.com/gmalette/pubsubstub/blob/78dfb5605aa0801350066056685f383b9fe8e2ba/lib/pubsubstub/stream_action.rb#L6

Could you also post an HTTP response? I'd like to see the headers etc.

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 5, 2020

Since I could witness the same behaviour even bypassing nginx (i.e. curl localhost:3000/events) I would not personally suspect nginx to be the cause of the issue. I'll collect the headers

@casperisfine
Copy link
Contributor

Since I could witness the same behaviour even bypassing nginx

Then it should be easy to reproduce locally no?

If you can produce this behavior at will let me know.

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 5, 2020

@casperisfine we took down the instance with pubsubstub as a separate process since we couldn't get it to work, we're now using Pubsubstub.use_persistent_connections = false so I have to recreate the instance in order to collect this information. please stand by

@casperisfine
Copy link
Contributor

Can't you just run pubusbstub on your local machine?

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 6, 2020

Here's what I see when from curl -v localhost:3000/events:

curl -v localhost:3000/events
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /events HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.58.0
> Accept: */*
> 

beyond that point it hangs forever, and I never receive a response

Here's what I see in the same environment on 0.26.0

curl -v localhost:3000/events
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /events HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/event-stream
< Cache-Control: no-cache
< X-Accel-Buffering: no
< Connection: keep-alive
< X-Request-Id: 8bccbcd3-f5b6-423a-8a64-f3c01a794998
< X-Runtime: 0.000786
< Transfer-Encoding: chunked
< 
id: 1583459027202
event: heartbeat
retry: 10000
data: ping

In both cases I am bypassing nginx

@casperisfine
Copy link
Contributor

So I built a debug repo with the informations you gave: https://github.com/casperisfine/pubsubstub-debug

I kinda have trouble running ruby 2.5.1, but I ran it with 2.5.3 and it works fine.

Can you try this repo to see if it reproduce the issue for you?

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 6, 2020

@casperisfine I think I have a better understanding of what's happening here. Running pubsubstub alone works fine but it appears to be the connection between shipit and pubsubstub, which is not induced by the standalone repo above

shipit is running on port 3000, as is the default. pubsubstub is running on port 8000, because of the line from the linked comment. as in the Procfile:

stream: bundle exec puma --config pubsubstub/puma_config.rb pubsubstub/config.ru --port 8000 --environment $RAILS_ENV
bundle exec puma -p 3000 --environment $RAILS_ENV

curl localhost:8000/events works fine:

curl -v localhost:8000/events
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /events HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.58.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: text/event-stream
< Cache-Control: no-cache
< X-Accel-Buffering: no
< Connection: keep-alive
< Transfer-Encoding: chunked
< 
id: 1583521641327
event: heartbeat
retry: 10000
data: ping

curl localhost:3000/events is what hangs:

curl -v localhost:3000/events
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /events HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.58.0
> Accept: */*
> 

So what's not clear to me is

  • Why this was induced in the default config (which did not have a pubsubstub as a separate proc) between 0.26.0 and 0.31.0, but I have a working config now (with Pubsubstub.use_persistent_connections = false) so I'm personally less concerned about that
  • What port pubsubstub should be running on, or how to indicate to shipit to forward correctly to port 8000

@byroot
Copy link
Contributor

byroot commented Mar 8, 2020

  • how to indicate to shipit to forward correctly to port 8000

It's not shipit's role to forward anything. When running pubsubstub externally, you have to do the proper routing in your reverse proxy (nginx).

e.g.:

  location /events {
    proxy_pass http://shipit-stream;
    rewrite /events(.*) /$1  break;

    proxy_set_header Host               $http_host;
    proxy_set_header Client-IP          $remote_addr;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Forwarded-Proto  https;
    proxy_set_header X-Forwarded-Port   443;
    proxy_set_header X-Request-Start    "t=${msec}000";

    proxy_redirect off;
    proxy_read_timeout 40s;
    proxy_buffering off;
  }

@pfhayes
Copy link
Contributor Author

pfhayes commented Mar 8, 2020

Thanks @byroot, that makes sense. I have the following questions:

  • Is the default setup (running pubsubstub in integrated form) still supported, or is now required to run pubsubstub as a separate process? In 0.26.0 the /events URL within shipit worked fine
  • If it is not supported, should the default be changed to Pubsubstub.use_persistent_connections = false? That works fine for me and was easiest to set up
  • Should the /events route within Shipit be removed?
    • When pubsubstub is running as a separate process it appears to just drop requests (and gradually increase resource consumption)
    • When Pubsubstub.use_persistent_connections = false, it just gives a 500 error

At the end of the day, I got my setup working (with use_persistent_connections = false) so don't have any further issues. But I am happy to help if I can make the default setup easier for future users. We are big fans of the project!

@byroot
Copy link
Contributor

byroot commented Mar 8, 2020

Is the default setup (running pubsubstub in integrated form) still supported, or is now required to run pubsubstub as a separate process?

It should still mostly work, it's just discouraged as longed-lived streaming requests don't mix well with short lived transactional request.

So there's probably a bug, (likely some mutex or something) causing pubsubstub to freeze when in process. I'll try to see if I can debug it, but either way I don't recommend running it this way (And I'm thinking about making Pubsubstub.use_persistent_connections = false the new default).

If it is not supported, should the default be changed to Pubsubstub.use_persistent_connections = false?

Seems like we just had the same idea.

Should the /events route within Shipit be removed?

Ideally yes, but in practice since the reverse proxy prevent it from ever be hit, it's not really worth the extra configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants