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

Extension for SSL / HTTPS / Cerbot encryption #6

Closed
CesMak opened this issue Nov 1, 2020 · 10 comments
Closed

Extension for SSL / HTTPS / Cerbot encryption #6

CesMak opened this issue Nov 1, 2020 · 10 comments
Labels

Comments

@CesMak
Copy link

CesMak commented Nov 1, 2020

Hey Miguel,

I just came across this great project and would like to test it a bit and then use it in production.

In order to use it in production I "upgraded all the requirements.txt files" and it worked like a charm even under ubuntu 20.04 focal fossa. I did not use any vagrant or virtual machine - just a clean ubuntu.

Next step was to run the site into a https ssl website using certbot and letsencrypt.

In order to achieve this I just did the following:

  1. generating an all.pem:
  • cat cert.pem privkey.pem > all.pem
  1. adding ip address in setup-all-in-one.sh
  • export HOST_IP_ADDRESS= idgaming.de #$(ip route get 8.8.8.8 | awk -F"src " 'NR==1{split($2,a," ");print a[1]}')
    inside mfvars:
  • export MICROFLACK_IP=idgaming.de
    -> or do I need https://idgaming.de or does this always have to be the 192.... localhost?
  1. changing the haproxy.tmpl
  • simply adding this line:
frontend http_frontend
    bind *:80
    bind *:443 ssl crt /etc/letsencrypt/live/idgaming.de/all.pem #<<<added line 
    {{ range $service := ls "/services" }}
    {{ if ls (printf "/services/%s/upstream" $service) }}
    acl {{ $service }}_acl path_beg {{ if exists (printf "/services/%s/location" $service) }}{{ getv (printf "/services/%s/location" $service) }}{{ else }}/{{ $service }}{{ end }}
    {{ if exists (printf "/services/%s/location" $service) }}
    {{ if eq (getv (printf "/services/%s/location" $service)) "/" }}
    default_backend {{ $service }}_backend
    {{ else }}
    use_backend {{ $service }}_backend if {{ $service }}_acl
    {{ end }}
    {{ else }}
    use_backend {{ $service }}_backend if {{ $service }}_acl
    {{ end }}
    {{ end }}
    {{ end }}

For me these changes did not work yet ...

I would be pleased if you could give me some hints.

I hope I got it right but I guess I do not need any ngnix?
Cause I have a current monolith running fine using ngnix and gunicorn.

I have more questions and would be happy to discuss with you (also some bugs I fixed which I noticed occuring in ubuntu 20.04).
Just contact me at [email protected]

@CesMak CesMak changed the title Extension for SSL Extension for SSL / HTTPS / Cerbot encryption Nov 1, 2020
@miguelgrinberg
Copy link
Owner

This project does not implement SSL, so the method of adding it is entirely your choice. My suggestion is that you look for tutorials on how to add SSL/Let' s Encrypt to HAProxy, since that is what this project uses, but if you prefer to put nginx in front of HAProxy and handle the SSL there that should work too.

@CesMak
Copy link
Author

CesMak commented Nov 2, 2020

Hey Miguel,
thanks for your quick answer. I managed it to configure haproxy such that I have a resolved https://domain name.

However I also had this problem with my monolith app: I get socketio handshake problems when using https. I never have these problems in http. I guess it has something to do with sticky sessions, socketio and https

Did you ever have socketio handshake problems using https?

The error is described in more detail here. However only nginx solutions are given. It is actually not a socketio error but a Websocket error. Thus I guess the websocket is not correcty setup.

chrome error:
error_in_chrome

firefox error:
error_in_firefox

Some details:
I used //cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.6/socket.io.min.js

This is my haproxy.cfg file:

global
    log /dev/log    local0
    log /dev/log    local1 notice
    #modern config Supports Firefox 63, Android 10.0, Chrome 70, Edge 75, Java 11, OpenSSL 1.1.1, Opera 57, and Safari 12.1
    # see: https://ssl-config.mozilla.org/#server=haproxy&version=2.1&config=modern&openssl=1.1.1d&guideline=5.6
    # test site with https://www.ssllabs.com/ssltest
    ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
    ssl-default-bind-options prefer-client-ciphers no-sslv3 no-tlsv10 no-tlsv11 no-tlsv12 no-tls-tickets
    ssl-default-server-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
    ssl-default-server-options no-sslv3 no-tlsv10 no-tlsv11 no-tlsv12 no-tls-tickets
defaults
    log    global
    mode    http
    option    httplog
    option    dontlognull
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    stats    enable
    stats    realm Haproxy\ Statistics
    stats    uri /stats
    stats    refresh 5s
frontend http_frontend_name
    bind *:80
    bind *:443 ssl crt /etc/haproxy/certs/all.pem
    # use https / ssl only - forward if not
    #redirect scheme https if !{ ssl_fc }
    acl messages_acl path_beg /api/messages
    use_backend messages_backend if messages_acl
    acl socketio_acl path_beg /socket.io
    use_backend socketio_backend if socketio_acl
    acl tokens_acl path_beg /api/tokens
    use_backend tokens_backend if tokens_acl
    acl ui_acl path_beg /
    default_backend ui_backend
    acl users_acl path_beg /api/users
    use_backend users_backend if users_acl
backend messages_backend
    balance roundrobin
    server idgaming.de  192.168.178.44:36848 check
backend socketio_backend
    balance source
    server idgaming.de  192.168.178.44:36849 check
backend tokens_backend
    balance roundrobin
    server idgaming.de  192.168.178.44:36847 check
backend ui_backend
    balance roundrobin
    server idgaming.de  192.168.178.44:36845 check
backend users_backend
    balance roundrobin
    server idgaming.de  192.168.178.44:36846 check

@miguelgrinberg
Copy link
Owner

To find out more about the 400 error you have to enable logging in the Socket.IO server.

@CesMak
Copy link
Author

CesMak commented Nov 3, 2020

In the mikroflack_socketio->boot.sh package I changed:

exec gunicorn -b 0.0.0.0:5000 -k eventlet --access-logfile - --error-logfile - app:app

to

exec gunicorn -b 0.0.0.0:5000 -k eventlet --access-logfile - --log-level debug --error-logfile gunicorn_error.log app:app

I also changed: 1.4.6 to 2.0.0 --> //cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.0/socket.io.min.js
(error still the same...)

The mflogs gives me (when connecting via https)

socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcc7o&sid=8855b30043c84bd88171cba4d7ccf2d8 HTTP/1.1" 200 0 "https://idgaming.de/">
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcce7&sid=ae6d0b2781a84d8e9594e8e61fb06c0f HTTP/1.1" 200 0 "https://idgaming.de/">
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcjAR&sid=ec2388004d2f489c8be2d314564fd8d9 HTTP/1.1" 200 262 "https://idgaming.de>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcjd_&sid=478b57a268c0494995a4d3525808db5c HTTP/1.1" 200 262 "https://idgaming.de>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCckco&sid=9b73e2616f2941f5a3cae327e5a0f0a0 HTTP/1.1" 200 262 "https://idgaming.de>
   users_36de3f859731|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "POST /api/users HTTP/1.1" 201 276 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Fir>
   users_36de3f859731|olaff olaf12
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcptA&sid=9b73e2616f2941f5a3cae327e5a0f0a0 HTTP/1.1" 200 261 "https://idgaming.de>
   users_36de3f859731|<flask.g of 'app'>
   users_36de3f859731|<flask.g of 'app'>
   users_36de3f859731|{'id': 2, 'created_at': 1604381785, 'updated_at': 1604381785, 'nickname': 'olaff', 'roomid': 0, 'last_seen_at': 1604381785, 'online': True, '_links': {'self': '/api/users>
   users_36de3f859731|172.17.0.1 - olaff [03/Nov/2020:05:36:25 +0000] "GET /api/users/me HTTP/1.1" 200 275 "-" "python-requests/2.24.0"
  tokens_9932a1d498be|<Response [200]>
  tokens_9932a1d498be|172.17.0.1 - olaff [03/Nov/2020:05:36:25 +0000] "POST /api/tokens HTTP/1.1" 200 139 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/2010010>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "POST /socket.io/?EIO=3&transport=polling&t=NMCcpw0&sid=9b73e2616f2941f5a3cae327e5a0f0a0 HTTP/1.1" 400 11 "https://idgaming.de>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:25 +0000] "POST /socket.io/?EIO=3&transport=polling&t=NMCcpwV&sid=9b73e2616f2941f5a3cae327e5a0f0a0 HTTP/1.1" 400 11 "https://idgaming.de>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:26 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcq70 HTTP/1.1" 200 119 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:30 +0000] "POST /socket.io/?EIO=3&transport=polling&t=NMCcr0z&sid=9e7b787630d746dab527030b61ef718a HTTP/1.1" 400 11 "https://idgaming.de>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:30 +0000] "POST /socket.io/?EIO=3&transport=polling&t=NMCcr1P&sid=9e7b787630d746dab527030b61ef718a HTTP/1.1" 400 11 "https://idgaming.de>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:30 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCcrAe HTTP/1.1" 200 119 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x>
socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:36:39 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=c2bacb8bc5ea4a2d8dd6845779c145e1 HTTP/1.1" 400 11 "-" "Mozilla/5.0 (X11; Ubuntu>

Howver if I connect to my site using http/ www mflogs gives me this (no error at all)

socketio_12ec0745b83e|172.17.0.1 - - [03/Nov/2020:05:38:01 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMCd3Nj&sid=a199da8e96c648c9abd4a3636015ef41 HTTP/1.1" 200 0 "https://idgaming.de/">
   users_36de3f859731|172.17.0.1 - - [03/Nov/2020:05:38:01 +0000] "POST /api/users HTTP/1.1" 201 278 "http://www.idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 >
   users_36de3f859731|olaffff olaf123
   users_36de3f859731|<flask.g of 'app'>
   users_36de3f859731|<flask.g of 'app'>
   users_36de3f859731|{'id': 3, 'created_at': 1604381881, 'updated_at': 1604381881, 'nickname': 'olaffff', 'roomid': 0, 'last_seen_at': 1604381881, 'online': True, '_links': {'self': '/api/use>
   users_36de3f859731|172.17.0.1 - olaffff [03/Nov/2020:05:38:01 +0000] "GET /api/users/me HTTP/1.1" 200 277 "-" "python-requests/2.24.0"
  tokens_9932a1d498be|<Response [200]>
  tokens_9932a1d498be|172.17.0.1 - olaffff [03/Nov/2020:05:38:01 +0000] "POST /api/tokens HTTP/1.1" 200 139 "http://www.idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20>
   users_36de3f859731|172.17.0.1 - - [03/Nov/2020:05:38:01 +0000] "PUT /api/users/me HTTP/1.1" 204 0 "-" "python-requests/2.24.0"
messages_d59728314e57|172.17.0.1 - - [03/Nov/2020:05:38:07 +0000] "POST /api/messages HTTP/1.1" 201 204 "-" "python-requests/2.24.0"

The debug error log does not contain much:

docker exec -it socketio_12ec0745b83e cat gunicorn_error.log
[2020-11-03 05:11:58 +0000] [1] [DEBUG] Current configuration:
  config: None
  bind: ['0.0.0.0:5000']
  backlog: 2048
  workers: 1
  worker_class: eventlet
  threads: 1
  worker_connections: 1000
  max_requests: 0
  max_requests_jitter: 0
  timeout: 30
  graceful_timeout: 30
  keepalive: 2
  limit_request_line: 4094
  limit_request_fields: 100
  limit_request_field_size: 8190
  reload: False
  reload_engine: auto
  reload_extra_files: []
  spew: False
  check_config: False
  preload_app: False
  sendfile: None
  reuse_port: False
  chdir: /app
  daemon: False
  raw_env: []
  pidfile: None
  worker_tmp_dir: None
  user: 0
  group: 0
  umask: 0
  initgroups: False
  tmp_upload_dir: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  forwarded_allow_ips: ['127.0.0.1']
  accesslog: -
  disable_redirect_access_to_syslog: False
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  errorlog: gunicorn_error.log
  loglevel: debug
  capture_output: False
  logger_class: gunicorn.glogging.Logger
  logconfig: None
  logconfig_dict: {}
  syslog_addr: udp://localhost:514
  syslog: False
  syslog_prefix: None
  syslog_facility: user
  enable_stdio_inheritance: False
  statsd_host: None
  dogstatsd_tags: 
  statsd_prefix: 
  proc_name: None
  default_proc_name: app:app
  pythonpath: None
  paste: None
  on_starting: <function OnStarting.on_starting at 0x7fdeb11a59d8>
  on_reload: <function OnReload.on_reload at 0x7fdeb11a5ae8>
  when_ready: <function WhenReady.when_ready at 0x7fdeb11a5bf8>
  pre_fork: <function Prefork.pre_fork at 0x7fdeb11a5d08>
  post_fork: <function Postfork.post_fork at 0x7fdeb11a5e18>
  post_worker_init: <function PostWorkerInit.post_worker_init at 0x7fdeb11a5f28>
  worker_int: <function WorkerInt.worker_int at 0x7fdeb10a10d0>
  worker_abort: <function WorkerAbort.worker_abort at 0x7fdeb10a11e0>
  pre_exec: <function PreExec.pre_exec at 0x7fdeb10a12f0>
  pre_request: <function PreRequest.pre_request at 0x7fdeb10a1400>
  post_request: <function PostRequest.post_request at 0x7fdeb10a1488>
  child_exit: <function ChildExit.child_exit at 0x7fdeb10a1598>
  worker_exit: <function WorkerExit.worker_exit at 0x7fdeb10a16a8>
  nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7fdeb10a17b8>
  on_exit: <function OnExit.on_exit at 0x7fdeb10a18c8>
  proxy_protocol: False
  proxy_allow_ips: ['127.0.0.1']
  keyfile: None
  certfile: None
  ssl_version: 2
  cert_reqs: 0
  ca_certs: None
  suppress_ragged_eofs: True
  do_handshake_on_connect: False
  ciphers: None
  raw_paste_global_conf: []
  strip_header_spaces: False
[2020-11-03 05:11:58 +0000] [1] [INFO] Starting gunicorn 20.0.4
[2020-11-03 05:11:58 +0000] [1] [DEBUG] Arbiter booted
[2020-11-03 05:11:58 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2020-11-03 05:11:58 +0000] [1] [INFO] Using worker: eventlet
[2020-11-03 05:11:58 +0000] [12] [INFO] Booting worker with pid: 12
[2020-11-03 05:11:58 +0000] [1] [DEBUG] 1 workers
[2020-11-03 05:12:43 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:43 +0000] [12] [DEBUG] POST /socket.io/
[2020-11-03 05:12:43 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:43 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:44 +0000] [12] [DEBUG] POST /socket.io/
[2020-11-03 05:12:46 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:46 +0000] [12] [DEBUG] POST /socket.io/
[2020-11-03 05:12:46 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:46 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:47 +0000] [12] [DEBUG] POST /socket.io/
[2020-11-03 05:12:48 +0000] [12] [DEBUG] Closing connection. 
[2020-11-03 05:12:48 +0000] [12] [DEBUG] Closing connection. 
[2020-11-03 05:12:49 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:50 +0000] [12] [DEBUG] POST /socket.io/
[2020-11-03 05:12:50 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:50 +0000] [12] [DEBUG] GET /socket.io/
[2020-11-03 05:12:51 +0000] [12] [DEBUG] POST /socket.io/
[2020-11-03 05:12:51 +0000] [12] [DEBUG] Closing connection. 

@miguelgrinberg
Copy link
Owner

I was referring to the logging in the Socket.IO server. Add logger=True and engineio_logger=True to the SocketIO() constructor.

@CesMak
Copy link
Author

CesMak commented Nov 3, 2020

These changes gives me:

I also get 404 besides these 503 errors:
image

mflogs shows me:

   users_c9a7ca1394e3|172.17.0.1 - - [03/Nov/2020:19:21:52 +0000] "POST /api/users HTTP/1.1" 201 275 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0"
   users_c9a7ca1394e3|huhu hans123
   users_c9a7ca1394e3|<flask.g of 'app'>
   users_c9a7ca1394e3|<flask.g of 'app'>
   users_c9a7ca1394e3|{'id': 3, 'created_at': 1604431312, 'updated_at': 1604431312, 'nickname': 'huhu', 'roomid': 0, 'last_seen_at': 1604431312, 'online': True, '_links': {'self': '/api/users/3', 'messag>
   users_c9a7ca1394e3|172.17.0.1 - huhu [03/Nov/2020:19:21:52 +0000] "GET /api/users/me HTTP/1.1" 200 274 "-" "python-requests/2.24.0"
  tokens_ece8bbadbc77|<Response [200]>
  tokens_ece8bbadbc77|172.17.0.1 - huhu [03/Nov/2020:19:21:52 +0000] "POST /api/tokens HTTP/1.1" 200 139 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82>
                   lb|[WARNING] 307/192152 (1) : Former worker #1 (155) exited with code 0 (Exit)
                   lb|2020-11-03T19:22:34Z a1fc28dc55ad ./confd[27]: INFO /usr/local/etc/haproxy/haproxy.cfg has md5sum 45182e6143785c05230b52214dfc369a should be 20f31062978c920c46ce933665da88de
                   lb|2020-11-03T19:22:34Z a1fc28dc55ad ./confd[27]: INFO Target config /usr/local/etc/haproxy/haproxy.cfg out of sync
                   lb|2020-11-03T19:22:34Z a1fc28dc55ad ./confd[27]: INFO Target config /usr/local/etc/haproxy/haproxy.cfg has been updated
                   lb|[WARNING] 307/192234 (1) : Reexecuting Master process
                   lb|[WARNING] 307/192234 (173) : Stopping frontend http_frontend_name in 0 ms.
                   lb|[WARNING] 307/192234 (173) : Stopping backend messages_backend in 0 ms.
                   lb|[WARNING] 307/192234 (173) : Stopping backend socketio_backend in 0 ms.
                   lb|[WARNING] 307/192234 (173) : Stopping backend tokens_backend in 0 ms.
                   lb|[WARNING] 307/192234 (173) : Stopping backend ui_backend in 0 ms.
                   lb|[WARNING] 307/192234 (173) : Stopping backend users_backend in 0 ms.
                   lb|[NOTICE] 307/192234 (1) : New worker #1 (182) forked
                   lb|[WARNING] 307/192234 (173) : Stopping frontend GLOBAL in 0 ms.
                   lb|[WARNING] 307/192234 (173) : Proxy http_frontend_name stopped (cumulated conns: FE: 2, BE: 0).
                   lb|[WARNING] 307/192234 (173) : Proxy messages_backend stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[WARNING] 307/192234 (173) : Proxy socketio_backend stopped (cumulated conns: FE: 0, BE: 8).
                   lb|[WARNING] 307/192234 (173) : Proxy tokens_backend stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[WARNING] 307/192234 (173) : Proxy ui_backend stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[WARNING] 307/192234 (173) : Proxy users_backend stopped (cumulated conns: FE: 0, BE: 1).
                   lb|[WARNING] 307/192234 (173) : Proxy GLOBAL stopped (cumulated conns: FE: 0, BE: 0).
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:22:40 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFZx2C HTTP/1.1" 404 232 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:8>
                   lb|[WARNING] 307/192242 (1) : Former worker #1 (173) exited with code 0 (Exit)
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:22:46 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFZyWf HTTP/1.1" 404 232 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:8>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:22:52 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFZz-o HTTP/1.1" 404 232 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:8>
                   lb|2020-11-03T19:22:54Z a1fc28dc55ad ./confd[27]: INFO /usr/local/etc/haproxy/haproxy.cfg has md5sum 20f31062978c920c46ce933665da88de should be b7cb40b5161452f14b154e6b00d2d68a
                   lb|2020-11-03T19:22:54Z a1fc28dc55ad ./confd[27]: INFO Target config /usr/local/etc/haproxy/haproxy.cfg out of sync
                   lb|2020-11-03T19:22:54Z a1fc28dc55ad ./confd[27]: INFO Target config /usr/local/etc/haproxy/haproxy.cfg has been updated
                   lb|[WARNING] 307/192254 (1) : Reexecuting Master process
                   lb|[WARNING] 307/192254 (182) : Stopping frontend http_frontend_name in 0 ms.
                   lb|[WARNING] 307/192254 (182) : Stopping backend messages_backend in 0 ms.
                   lb|[WARNING] 307/192254 (182) : Stopping backend tokens_backend in 0 ms.
                   lb|[WARNING] 307/192254 (182) : Stopping backend ui_backend in 0 ms.
                   lb|[WARNING] 307/192254 (182) : Stopping backend users_backend in 0 ms.
                   lb|[WARNING] 307/192254 (182) : Stopping frontend GLOBAL in 0 ms.
                   lb|[WARNING] 307/192254 (182) : Proxy http_frontend_name stopped (cumulated conns: FE: 1, BE: 0).
                   lb|[WARNING] 307/192254 (182) : Proxy messages_backend stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[WARNING] 307/192254 (182) : Proxy tokens_backend stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[WARNING] 307/192254 (182) : Proxy ui_backend stopped (cumulated conns: FE: 0, BE: 3).
                   lb|[WARNING] 307/192254 (182) : Proxy users_backend stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[WARNING] 307/192254 (182) : Proxy GLOBAL stopped (cumulated conns: FE: 0, BE: 0).
                   lb|[NOTICE] 307/192254 (1) : New worker #1 (191) forked
                   lb|[WARNING] 307/192254 (191) : Server socketio_backend/idgaming.de is DOWN, reason: Layer4 connection problem, info: "Connection refused", check duration: 0ms. 0 active and 0 backup s>
                   lb|[NOTICE] 307/192254 (191) : haproxy version is 2.2.4-de45672
                   lb|[ALERT] 307/192254 (191) : backend 'socketio_backend' has no server available!
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:22:58 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFZ_Sz HTTP/1.1" 404 232 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:8>
                   lb|[WARNING] 307/192258 (1) : Former worker #1 (182) exited with code 0 (Exit)

@miguelgrinberg
Copy link
Owner

Sorry, but something isn't right there. You don't seem to be running the socketio service, which is the one that should be writing those logs.

@CesMak
Copy link
Author

CesMak commented Nov 3, 2020

I changed now in the socketio -> app.py this line:

# adding message_queue=message_queue, logger=True, engineio_logger=True
socketio = SocketIO(app, message_queue=message_queue, logger=True, engineio_logger=True)

after that my docker container always restarts.... I guess the line is wrong....

I deleted engineio_logger in this line and now the socketio starts but I guess I do not have all logs now:

./mflogs shows now

socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:46:48 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfIe1&sid=a45f645bc98d4976b64ddfa10612>
      ui_9ff241a1598e|Use socket io: True
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:49 +0000] "GET / HTTP/1.1" 200 3892 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gec>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/models/user.js HTTP/1.1" 200 0 "https://idgaming.de/" "Mozilla/5.0 (X1>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/views/user.js HTTP/1.1" 200 0 "https://idgaming.de/" "Mozilla/5.0 (X11>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/views/post_form.js HTTP/1.1" 200 0 "https://idgaming.de/" "Mozilla/5.0>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/models/user_list.js HTTP/1.1" 304 0 "https://idgaming.de/" "Mozilla/5.>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/models/message.js HTTP/1.1" 304 0 "https://idgaming.de/" "Mozilla/5.0 >
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/models/message_list.js HTTP/1.1" 304 0 "https://idgaming.de/" "Mozilla>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/views/message_list.js HTTP/1.1" 200 0 "https://idgaming.de/" "Mozilla/>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/app.js HTTP/1.1" 200 0 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubunt>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/views/login_form.js HTTP/1.1" 200 0 "https://idgaming.de/" "Mozilla/5.>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/models/token.js HTTP/1.1" 304 0 "https://idgaming.de/" "Mozilla/5.0 (X>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/views/user_list.js HTTP/1.1" 304 0 "https://idgaming.de/" "Mozilla/5.0>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:50 +0000] "GET /static/views/message.js HTTP/1.1" 304 0 "https://idgaming.de/" "Mozilla/5.0 (>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:46:51 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfTB8 HTTP/1.1" 200 119 "https://idgam>
   users_c9a7ca1394e3|172.17.0.1 - - [03/Nov/2020:19:46:51 +0000] "GET /api/users?updated_since=0 HTTP/1.1" 200 2016 "https://idgaming.de/" "Mozilla/>
      ui_9ff241a1598e|172.17.0.1 - - [03/Nov/2020:19:46:52 +0000] "GET /static/styles.css HTTP/1.1" 200 0 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64>
messages_8d1daa06fa22|172.17.0.1 - - [03/Nov/2020:19:46:52 +0000] "GET /api/messages?updated_since=0 HTTP/1.1" 200 21 "https://idgaming.de/" "Mozilla>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:46:53 +0000] "GET /socket.io/?EIO=3&transport=websocket&sid=a1aad768dc974791a37ffca4fc3d1b0a HTT>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:46:59 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfGlT&sid=781bb22b53f441f3a7e924d70652>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:47:00 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfH0V&sid=e06aa4cf10914773bf4455374692>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:47:02 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfON0&sid=e415af3e24c24719af7d11782629>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:47:02 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfSIF&sid=a57e6d6b50874c2990580c96b25d>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:47:02 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfTIK&sid=a1aad768dc974791a37ffca4fc3d>
   users_c9a7ca1394e3|172.17.0.1 - - [03/Nov/2020:19:47:02 +0000] "POST /api/users HTTP/1.1" 201 276 "https://idgaming.de/" "Mozilla/5.0 (X11; Ubuntu>
   users_c9a7ca1394e3|sowas 1232
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:47:02 +0000] "GET /socket.io/?EIO=3&transport=polling&t=NMFfV-E&sid=a1aad768dc974791a37ffca4fc3d>
   users_c9a7ca1394e3|<flask.g of 'app'>
   users_c9a7ca1394e3|<flask.g of 'app'>
   users_c9a7ca1394e3|{'id': 7, 'created_at': 1604432822, 'updated_at': 1604432822, 'nickname': 'sowas', 'roomid': 0, 'last_seen_at': 1604432822, 'on>
   users_c9a7ca1394e3|172.17.0.1 - sowas [03/Nov/2020:19:47:02 +0000] "GET /api/users/me HTTP/1.1" 200 275 "-" "python-requests/2.24.0"
  tokens_ece8bbadbc77|<Response [200]>
  tokens_ece8bbadbc77|172.17.0.1 - sowas [03/Nov/2020:19:47:02 +0000] "POST /api/tokens HTTP/1.1" 200 139 "https://idgaming.de/" "Mozilla/5.0 (X11; U>
socketio_4c4010923cb1|172.17.0.1 - - [03/Nov/2020:19:47:02 +0000] "POST /socket.io/?EIO=3&transport=polling&t=NMFfW1K&sid=a1aad768dc974791a37ffca4fc3>

image

@miguelgrinberg
Copy link
Owner

The logging line looks fine to me. If you are getting a Python error then the log should have a stack trace.

@CesMak
Copy link
Author

CesMak commented Nov 3, 2020

I saw this error here:
https://stackoverflow.com/questions/63113478/flask-socketio-issues-with-https-http-wss-unable-to-connect-in-heroku

and could solve the error using:
socketio -> app.py:

socketio = SocketIO(app, message_queue=message_queue, cors_allowed_origins=['http://idgaming.de', 'https://idgaming.de'], logger=True)

Thanks for your help you can close this issue now :)

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

No branches or pull requests

2 participants