mercredi 2 septembre 2015

Cannot get Sever Sent Events to work on AWS Elastic Beanstalk

I have an application that I have built using Node.js to deliver Server Sent Events. The application works fine on my local environment but now I have deployed it to AWS Elastic Beanstalk it is not working.

Having researched around it appears that the issue is explained in this post.

I have amended the configuration now, but I still have the issue that the EventSource cannot connect, and eventually times out. If I cURL to the end point it works as I would expect, but when I connect via JavaScript it fails.

This is my Nginx configuration:-

    upstream nodejs {
            server 127.0.0.1:8081;
            keepalive 256;
    }

    server {
            listen 8080;
            if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2})") {
                    set $year $1;
                    set $month $2;
                    set $day $3;
                    set $hour $4;
            }
            access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
            access_log  /var/log/nginx/access.log  main;


            location / {
                    proxy_pass  http://nodejs;
                    proxy_set_header   Connection "";
                    proxy_http_version 1.1;
                    chunked_transfer_encoding off;
                    proxy_buffering off;
                    proxy_cache off;
                    proxy_set_header        Host            $host;
                    proxy_set_header        X-Real-IP       $remote_addr;
                    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            }

    gzip on;
    gzip_comp_level 4;
    gzip_types text/html text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;


    }

Does anyone have a clue why this is not working?




Aucun commentaire:

Enregistrer un commentaire