amqpcpp icon indicating copy to clipboard operation
amqpcpp copied to clipboard

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

Open fxconfig opened this issue 7 years ago • 0 comments

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;
}

}`

fxconfig avatar Sep 12 '17 09:09 fxconfig