4

I am using Rails 5.1.5. I have used nginx and puma for deployment of my app.Basically, I want to record all data sent by IoT device and store that data in one table.IoT device is using TCP for communication with server. so I have used stream directive of nginx to communicate with device and I want to transfer the tcp request to puma for processing purpose. Puma is only accepting http requests, so it raises following error.

 HTTP parse error, malformed request : #<Puma::HttpParserError: Invalid HTTP format, parsing fails.>

I have confiured nginx.conf file like below

    stream {
    log_format  main  '$time_iso8601 $remote_addr'
                      '$protocol  $status $bytes_sent $bytes_received '
                      '$session_time $upstream_addr '
                      '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

    access_log  /var/log/nginx/access.log  main;

    server {
        listen port;
        proxy_pass app;
    }

    upstream app {
        server path of puma.sock;
    }
}
Smit Sonani
  • 115
  • 6
darshi kothari
  • 642
  • 1
  • 5
  • 12

0 Answers0