c++activemq-cpp

terminate called after throwing an instance of 'std::length_error'


I m getting the following exception. and not sure what s causing it.

any ideas?

here is my connection string:

std::string brokerURI = "tcp://127.0.0.1:61613?wireFormat=stomp";

and this is the error:

E 05-150926.792540  4680 yfor_lookup4: invalid hostname: <(null)>
Invalid argument
        FILE: decaf/internal/net/tcp/TcpSocket.cpp, LINE: 222
        FILE: decaf/internal/net/tcp/TcpSocket.cpp, LINE: 251
        FILE: decaf/net/Socket.cpp, LINE: 327
        FILE: activemq/transport/tcp/TcpTransport.cpp, LINE: 154
        FILE: activemq/transport/tcp/TcpTransportFactory.cpp, LINE: 117
        FILE: activemq/transport/tcp/TcpTransportFactory.cpp, LINE: 59
        FILE: activemq/core/ActiveMQConnectionFactory.cpp, LINE: 322
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_S_create
Aborted (core dumped) 

Solution

  • From your error message it seems you ended up with an empty string. The actual error is probably produced by passing a negative size to a std::string constructor. This could e.g. result from using the result of s.find('?'): if the corresponding character isn't found, std::string::npos is returned which is normally a negative number.