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

AMQP(con_str) need two '/' if vhost is default #69

Open
fxconfig opened this issue Sep 12, 2017 · 0 comments
Open

AMQP(con_str) need two '/' if vhost is default #69

fxconfig opened this issue Sep 12, 2017 · 0 comments

Comments

@fxconfig
Copy link

when constructing AMQP using "guest:guesu@localhost:5672/", it would throw a exception.
AMQPException.cpp line 38 39 will get invalid data, cause an uncatched exception

So I think there should have an additional judgment in
void AMQP::parseHostPort(string hostPortString )
{
...
if (!vhost.size()) vhost.append("/");
}

`AMQPException::AMQPException( amqp_rpc_reply_t * res) {
if( res->reply_type == AMQP_RESPONSE_LIBRARY_EXCEPTION) {
this->message = res->library_error ? strerror(res->library_error) : "end-of-stream";
}

if( res->reply_type == AMQP_RESPONSE_SERVER_EXCEPTION) {
	char buf[512];
	memset(buf,0,512);
	this->code = 0;

	if(res->reply.id == AMQP_CONNECTION_CLOSE_METHOD) {
		amqp_connection_close_t *m = (amqp_connection_close_t *) res->reply.decoded;
		this->code = m->reply_code;

		sprintf(buf, "server connection error %d, message: %.*s",
			m->reply_code,
			(int) m->reply_text.len,
			(char *) m->reply_text.bytes
		);
	} else if(res->reply.id == AMQP_CHANNEL_CLOSE_METHOD) {
		amqp_channel_close_t *n = (amqp_channel_close_t *) res->reply.decoded;
		this->code = n->reply_code;

		sprintf(buf, "server channel error %d, message: %.*s class=%d method=%d",
			n->reply_code,
			(int) n->reply_text.len,
			(char *) n->reply_text.bytes,
			(int) n->class_id,
			n->method_id
		);
	} else {
		sprintf(buf, "unknown server error, method id 0x%08X", res->reply.id);
	}
	this->message=buf;
}

}`

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

No branches or pull requests

1 participant