cwzx / nngpp

C++ wrapper around the nanomsg NNG API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Messaging with wss://

nmset opened this issue · comments

commented

While testing a req-rep minimal setup with wss://, no message is sent or received when using IPV6 addresses. With IPV4 ones, or with 'localhost', the client/server messaging is straightforward. Firewall is off on the host.

nng_wss_ipv6.cpp.txt

The attached file may demonstrate it.

I don't know if it's the right place to seek help resolving this. I'm posting here because I'm using nngpp, and not the C interface directly.

Regards.

The flags you're passing to listen/dial are wrong. NNG_AF_INET etc are not flags.

  • Flags for listen are ignored.
  • Dial only supports NNG_FLAG_NONBLOCK. By passing NNG_AF_INET you're accidentally enabling async dialing which is why you can't see the connection error.

I found the following:

  • TLS is not required and can be removed from the demo.
  • Using ipv6 address works with tcp:// but fails with ws:// on the dial with error Connection refused.
TEST_CASE("ws ipv6", "[ip]") {
	auto addr = "ws://[::1]:8003";
	nng::socket rep_socket = nng::rep::open();
	REQUIRE_NOTHROW( rep_socket.listen( addr ) );

	nng::socket req_socket = nng::req::open();
	REQUIRE_NOTHROW( req_socket.dial( addr ) );

	REQUIRE_NOTHROW( req_socket.send("hello") );
	REQUIRE( rep_socket.recv() == "hello" );
	
	REQUIRE_NOTHROW( rep_socket.send("world") );
	REQUIRE( req_socket.recv() == "world" );
}

I don't know of a good reason for this behaviour. Definitely ask at nng.

commented

Thank you very much for a detailed time-saving reply .
I'll just drop wss:// and use tls+tcp://.
Best regards.