SimpleAmqpClient icon indicating copy to clipboard operation
SimpleAmqpClient copied to clipboard

SimpleAmqpClient throw "a socket error occurred" when creating new connection

Open ktawfik opened this issue 7 years ago • 4 comments

I am creating a simple c++ client to publish messages to rabbitmq,

using the below snippet

#include <iostream>
#include <SimpleAmqpClient/SimpleAmqpClient.h>

using namespace std;
using namespace AmqpClient;


int main()
{
	try {
		Channel::ptr_t connection = Channel::Create("localhost", 5672, "code_client", "1234");
	}
	catch (ConnectionException::exception e) {
		std::cout << "ERROR has occurred  " <<  e.what() <<endl;
	}
}

however I am getting a socket error occurred, to make sure that the connection attributes (ip, port, username, password) are correct, I created a java and c# apps and both able to connect successfully!.

I didn't build the SimpleAmqpClient, I downloaded it from NuGet Manager, I am using VS 2017 on windows 7.

Any ideas?

ktawfik avatar Jun 20 '18 01:06 ktawfik

Any errors in the broker logs?

alanxz avatar Jul 08 '18 06:07 alanxz

The same error. OS: Windows 10, Development Environment: Visual Studio 15, dependencies: SImpleAmqpClient 2.4.0 boost/1.68 rabbitmq.4/0.6.0

At some point, incorrect processing of string variables occurs. As a result, incorrect variables are inserted into the "Channel :: Channel" constructor, shifted by several characters, or even the memory allocated for variables is unreadable (the message "Error reading characters in a string").

As a result, the "getaddrinfo" in "amqp_socket::amqp_open_socket_noblock" function cannot read the IP address for connection and throws an error.

I had cases when the line was displaced on some characters to the left. However, even in these cases, variables with a login and password are passed to the amqp_open_socket_noblock function as unreadable.

ahousetov15 avatar Oct 03 '18 15:10 ahousetov15

Sorry for the very late reply, I had to stop looking into it back then, anyways, here is what I got from the broker log:

2018-12-25 01:07:33.328 [info] <0.17001.32> accepting AMQP connection <0.17001.32> ([::1]:64124 -> [::1]:5672) 2018-12-25 01:07:36.340 [warning] <0.17001.32> closing AMQP connection <0.17001.32> ([::1]:64124 -> [::1]:5672): {handshake_error,tuning,0,{exit,{amqp_error,not_allowed,"negotiated channel_max = 0 is higher than the maximum allowed value (2047)",'connection.tune'},'connection.tune_ok',[{rabbit_misc,protocol_error,1,[{file,"src/rabbit_misc.erl"},{line,304}]},{rabbit_reader,handle_method0,2,[{file,"src/rabbit_reader.erl"},{line,1163}]},{rabbit_reader,handle_method0,3,[{file,"src/rabbit_reader.erl"},{line,1107}]},{rabbit_reader,handle_input,3,[{file,"src/rabbit_reader.erl"},{line,1022}]},{rabbit_reader,recvloop,4,[{file,"src/rabbit_reader.erl"},{line,466}]},{rabbit_reader,run,1,[{file,"src/rabbit_reader.erl"},{line,448}]},{rabbit_reader,start_connection,4,[{file,"src/rabbit_reader.erl"},{line,353}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}}

AgoloKarimTawfik avatar Dec 24 '18 23:12 AgoloKarimTawfik

I saw that, it has been solved in rabbitmq-c repo https://github.com/lazedo/rabbitmq-c/commit/0546de3cd90085a914612f212e9a0444c7954282 , however I am not sure how this will be reflected in nugget package I am installing via VS.

AgoloKarimTawfik avatar Dec 24 '18 23:12 AgoloKarimTawfik