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

HTTPClientSession not working with UNIX_LOCAL SocketAddress #2578

Closed
adalton opened this issue Jan 9, 2019 · 4 comments
Closed

HTTPClientSession not working with UNIX_LOCAL SocketAddress #2578

adalton opened this issue Jan 9, 2019 · 4 comments

Comments

@adalton
Copy link

adalton commented Jan 9, 2019

Expected behavior

I'm trying to use Poco::Net::HTTPClientSession to communicate with Docker, which exposes an HTTP interface over a UNIX domain socket. I would expect HTTPClientSession to be SocketAddress agnostic, and for it to be able to talk HTTP over whatever socket the caller supplies.

Actual behavior

The constructor for HTTPClientSession calls host() on the supplied SocketAddress:
https://github.com/pocoproject/poco/blob/develop/Net/src/HTTPClientSession.cpp#L72

Unfortunately, host() throws and InvalidAccessException:
https://github.com/pocoproject/poco/blob/develop/Net/include/Poco/Net/SocketAddressImpl.h#L211

Steps to reproduce the problem

The following program will trigger the problem:

#include <string>
#include <Poco/Net/HTTPClientSession.h>

int main()
{
    std::string socketFilename = "/path/to/some/domain.socket";
    Poco::Net::HTTPClientSession session(
        Poco::Net::SocketAddress(Poco::Net::SocketAddress::UNIX_LOCAL,
                                 socketFilename));

        return 0;
}

Compiled with:

$ g++ -ggdb ex.cc -lPocoNet

Running this results in:

$ ./a.out
terminate called after throwing an instance of 'Poco::InvalidAccessException'
  what():  Invalid access
Aborted (core dumped)

The backtrace looks like:

(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007ffff6d71121 in __GI_abort () at abort.c:79
#2  0x00007ffff7757fd5 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so.6
#3  0x00007ffff7755be6 in ?? () from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so.6
#4  0x00007ffff7755c31 in std::terminate() () from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so.6
#5  0x00007ffff7755e73 in __cxa_throw () from /usr/lib/gcc/x86_64-pc-linux-gnu/7.3.0/libstdc++.so.6
#6  0x00007ffff7b888bc in Poco::Net::Impl::LocalSocketAddressImpl::host (this=<optimized out>)
    at /usr/src/debug/dev-libs/poco-1.9.0/poco-poco-1.9.0-release/Net/include/Poco/Net/SocketAddressImpl.h:212
#7  0x00007ffff7b85a25 in Poco::Net::SocketAddress::host (this=this@entry=0x7fffffffd838)
    at /usr/src/debug/dev-libs/poco-1.9.0/poco-poco-1.9.0-release/Net/src/SocketAddress.cpp:208
#8  0x00007ffff7b2eac5 in Poco::Net::HTTPClientSession::HTTPClientSession (this=0x7fffffffd860, address=...)
    at /usr/src/debug/dev-libs/poco-1.9.0/poco-poco-1.9.0-release/Net/src/HTTPClientSession.cpp:67
#9  0x0000555555555934 in main () at ex.cc:15

POCO version

$ equery --quiet list poco
dev-libs/poco-1.9.0

Compiler and version

$ g++ --version
g++ (Gentoo 7.3.0-r3 p1.4) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Operating system and version

$ cat /etc/os-release 
NAME=Gentoo
ID=gentoo
PRETTY_NAME="Gentoo/Linux"
ANSI_COLOR="1;32"
HOME_URL="https://www.gentoo.org/"
SUPPORT_URL="https://www.gentoo.org/support/"
BUG_REPORT_URL="https://bugs.gentoo.org/"

Other relevant information

N/A

@cheese
Copy link
Contributor

cheese commented Jun 24, 2020

Still valid with 1.9.4

@sirzooro
Copy link

sirzooro commented Nov 3, 2020

I also encountered this bug. I also found a workaround - create StreamSocket and pass it to HTTPClientSession:

Poco::Net::SocketAddress socketAddress(Poco::Net::SocketAddress::UNIX_LOCAL, socketPath);
Poco::Net::StreamSocket socket(socketAddress);
Poco::Net::HTTPClientSession session(socket);

@github-actions
Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Jun 22, 2022
@aleks-f aleks-f added enhancement and removed stale labels Jun 22, 2022
@aleks-f aleks-f added this to the Release 1.13.0 milestone Jun 22, 2022
@aleks-f aleks-f self-assigned this Jun 22, 2022
Copy link

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Nov 24, 2023
@aleks-f aleks-f removed the stale label Nov 25, 2023
@aleks-f aleks-f changed the title Poco::Net::HTTPClientSession does not work with a Poco::Net::SocketAddress with family UNIX_LOCAL HTTPClientSession not working with UNIX_LOCAL SocketAddress Nov 25, 2023
@aleks-f aleks-f added the fixed label Nov 25, 2023
aleks-f added a commit that referenced this issue Nov 26, 2023
* fix(sharedMemory): x64 size error #2976

* chore: add Util dependency to Prometheus samples

* fix(HTTPClientSession): not working with UNIX_LOCAL SocketAddress #2578

* fix(WebSocketTest): supress connection reset exception assertion

* fix(PollSet): wait on premature epoll_wait return; reinforce tests for windows

* fix(build): add DataTest dependency to Makefile

* fix(Task): intermittently hanging test and some other improvements

* fix(Net): PollSet loop; suppress test WebSocket handler shutdown IOExeption
aleks-f added a commit that referenced this issue Nov 27, 2023
* fix(sharedMemory): x64 size error #2976

* chore: add Util dependency to Prometheus samples

* fix(HTTPClientSession): not working with UNIX_LOCAL SocketAddress #2578

* fix(WebSocketTest): supress connection reset exception assertion

* fix(PollSet): wait on premature epoll_wait return; reinforce tests for windows

* fix(build): add DataTest dependency to Makefile

* fix(Task): intermittently hanging test and some other improvements

* fix(Net): PollSet loop; suppress test WebSocket handler shutdown IOExeption
@aleks-f aleks-f closed this as completed Dec 22, 2023
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

4 participants