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

Bring up HTTP Server on Unix Domain Socker with alpakka #2886

Open
scheruku-in opened this issue Jul 26, 2022 · 0 comments
Open

Bring up HTTP Server on Unix Domain Socker with alpakka #2886

scheruku-in opened this issue Jul 26, 2022 · 0 comments

Comments

@scheruku-in
Copy link

scheruku-in commented Jul 26, 2022

Hello,
I am trying to bring up REST API server on UDS with alpakka as documented in https://doc.akka.io/docs/alpakka/current/unix-domain-socket.html#
Here is the sample code .

        val serverSideFlow = Flow[ByteString]
          .buffer(1, OverflowStrategy.backpressure)
          .wireTap(bytes => received.success(bytes))
        UnixDomainSocket().bindAndHandle(serverSideFlow, Paths.get(socketPath))

It seems to start the server on UDS but not sure how to specify the routes as the above example doesn't seem to accept route info.

netstat -anp| grep "LISTEN"
tcp6       0      0 :::16501                :::*                    LISTEN      49/java             
tcp6       0      0 172.30.187.35:36885     :::*                    LISTEN      49/java             
tcp6       0      0 172.30.187.35:42999     :::*                    LISTEN      49/java                   
tcp6       0      0 :::32841                :::*                    LISTEN      49/java             
tcp6       0      0 :::39053                :::*                    LISTEN      49/java             
unix  2      [ ACC ]     STREAM     LISTENING     899427761 49/java              /tmp/.java_pid49.tmp
unix  2      [ ACC ]     STREAM     LISTENING     899404587 49/java              /tmp/uds-socket/uds.sock

Trying to access using socket file hangs.

 curl -k -v -X GET "http://localhost" --unix-socket /tmp/uds-socket/uds.sock
Note: Unnecessary use of -X or --request, GET is already inferred.
* Rebuilt URL to: http://localhost/
*   Trying /tmp/uds-socket/uds.sock...
* Connected to localhost (/tmp/uds-socket/uds.sock) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/7.61.1
> Accept: */*

I found few examples for accessing a REST endpoint which is already exposed on a particular socket path (ex: https://stackoverflow.com/questions/51565935/how-to-access-rest-api-on-a-unix-domain-socket-with-akka-http-or-alpakka), but I haven't come across any sample on hosting REST end points on UDS using alpakka or akka-http.

Would you please let me know if its possible? If yes, kindly share the sample.

Regards,
Sobha

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

No branches or pull requests

2 participants