refer tabish121 wrote: > >> >> I am running it on vs .net 2003 ... could that be a problem then. >> I built the lib file using maven and set the linker to this lib file. > > Could be, then again it might not. We are not building or testing with > the VC 2003 compiler, there could be something there that is not > compatible. > >> >> I am running it on .net 2003 >> >> As I wrote earlier .... an invalid handle is getting returned from >> socket = SocketFactory::createSocket( properties ); >> >> And then it throws an exception on this line >> // Cast it to an IO transport so we can wire up the socket >> // input and output streams. >> IOTransport* ioTransport = dynamic_cast<IOTransport*>( next ); > > I don't think this is really the problem, there is probably an exception > happening before this line that screws things up. Generally the VC > debugger will stop on the line after the line where the exception is. > You should also examine the next pointer in the debugger to see what it > is really pointing too, if its not an IOTransport, then something has > gone terribly wrong. > >> >> What could be the reasons of getting an invalid handle from the > statement >> socket = SocketFactory::createSocket( properties ); > > There are many reasons; one being that Winsock is retarded. Like I said > earlier, I would step through the tcpsocket connect() to see where the > problem is occurring, there are several calls in there that could be > breaking. > >> >> Regards >> >> Lalit .... >> >> tabish121 wrote: >> > >> > >> > Sounds like for whatever reason a socket can't be opened to the > broker. >> > You may have to step through the code in the tcpsocket::connect and > see >> > what line is failing. >> > >> > The code from the website builds and runs fine here, you may need to >> > refresh your browser cache to see the latest, or go right to SVN and > get >> > it from the examples folder in activemq-cpp. There is a VC++ 2005 >> > project file in there as well. You can download 2005 for free, it > may >> > be worth it to try that and see if there is something in the > settings >> > that is different from yours. >> > >> >> >> >> Tim, >> >> >> >> Actually my broker had gone down so i gave some wrong info ... > problem >> > is >> >> something else, please go through this explanation of what i found. >> >> >> >> If you look at the main function in the activemq-cpp client given > on >> > our >> >> site >> >> I am just pasting it here now. It says. >> >> >> >> HelloWorldProducer producer( 1000 ); >> >> HelloWorldConsumer consumer( 5000 ); >> >> >> >> // Start the consumer thread. >> >> Thread consumerThread( &consumer ); >> >> consumerThread.start(); >> >> >> >> // Start the producer thread. >> >> Thread producerThread( &producer ); >> >> producerThread.start(); >> >> >> >> // Wait for the threads to complete. >> >> producerThread.join(); >> >> consumerThread.join(); >> >> >> >> When I debug the call goes to >> >> socket->connect( host, port ); // this is inside the > class >> >> bufferedsocket.cpp >> >> >> >> after this it executes the connect method inside the class >> > tcpsocket.cpp >> >> but when the call comes out of this method it shows a INVALID > HANDLE >> > in >> >> the >> >> debug variable socket value >> >> >> >> Then from the producer call again goes to >> >> bufferedsocket.cpp and executes the >> >> socket->connect(host, port); method >> >> >> >> AFter all this is done >> >> it bombs in the constructor of tcptransport.cpp >> >> IOTransport* ioTransport = dynamic_cast<IOTransport*>( next > ); >> >> >> >> and the value of the variable socket in debug mode at this point of >> > time >> >> before executing this statement is INVALID_SOCKET_HANDLE=??? >> >> >> >> Here is the exception then >> >> >> >> - ex {message={"caught unknown exception"} stackTrace={first=??? >> > last=???} >> >> } >> >> activemq::exceptions::ActiveMQException & >> >> - cms::CMSException {...} cms::CMSException >> >> + __vfptr 0x00484278 const >> >> activemq::exceptions::ActiveMQException::`vftable' * >> >> - message {"caught unknown exception"} >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >> - std::_String_val<char,std::allocator<char> > {_Alval={...} } >> >> std::_String_val<char,std::allocator<char> > >> >> std::_String_base {...} const std::_String_base >> >> + _Alval {...} std::allocator<char> >> >> - _Bx {_Buf=0x0069f9bc "po4" _Ptr=0x00346f70 "caught unknown >> > exception" } >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >::_Bxty >> >> + _Buf 0x0069f9bc "po4" char [16] >> >> - _Ptr 0x00346f70 "caught unknown exception" char * >> >> 99 'c' char >> >> _Mysize 24 unsigned int >> >> _Myres 31 unsigned int >> >> - stackTrace {first=??? last=???} >> >> >> > > std::vector<std::pair<std::basic_string<char,std::char_traits<char>,std: >> > :a >> >> llocator<char> >> >> >> >>>,int>,std::allocator<std::pair<std::basic_string<char,std::char_traits > < >> > ch >> >> ar>,std::allocator<char> >> >> >,int> > > >> >> - >> >> >> > > std::_Vector_val<std::pair<std::basic_string<char,std::char_traits<char> >> > ,s >> >> td::allocator<char> >> >> >> >>>,int>,std::allocator<std::pair<std::basic_string<char,std::char_traits > < >> > ch >> >> ar>,std::allocator<char> >> >> >,int> > > {_Alval={...} } >> >> >> > > std::_Vector_val<std::pair<std::basic_string<char,std::char_traits<char> >> > ,s >> >> td::allocator<char> >> >> >> >>>,int>,std::allocator<std::pair<std::basic_string<char,std::char_traits > < >> > ch >> >> ar>,std::allocator<char> >> >> >,int> > > >> >> - _Alval {...} >> >> >> > > std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,s >> > td >> >> ::allocator<char> >> >> >,int> > >> >> >> >> >> > > std::_Allocator_base<std::pair<std::basic_string<char,std::char_traits<c >> > ha >> >> r>,std::allocator<char> >> >> >,int> > {...} >> >> >> > > std::_Allocator_base<std::pair<std::basic_string<char,std::char_traits<c >> > ha >> >> r>,std::allocator<char> >> >> >,int> > >> >> - _Myfirst 0x00b82770 >> >> {first={"D:\PCData\cpp2\activemq-cpp\win32- >> >> msvc\..\src\main\activemq\transport\TcpTransport.cpp"} >> >> second=59} >> >> >> > > std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<c >> > ha >> >> r> >> >> >,int> * >> >> + first >> >> {"D:\PCData\cpp2\activemq-cpp\win32- >> >> msvc\..\src\main\activemq\transport\TcpTransport.cpp"} >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >> second 59 int >> >> - _Mylast 0x00b827b0 {first={???} second=3473784} >> >> >> > > std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<c >> > ha >> >> r> >> >> >,int> * >> >> - first {???} >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >> + std::_String_val<char,std::allocator<char> > {_Alval={...} } >> >> std::_String_val<char,std::allocator<char> > >> >> + _Bx {_Buf=0x00b827b4 "<<<<" _Ptr=0xabababab <Bad Ptr> } >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >::_Bxty >> >> _Mysize 32380142 unsigned int >> >> _Myres 3529288 unsigned int >> >> second 3473784 int >> >> - _Myend 0x00b827b0 {first={???} second=3473784} >> >> >> > > std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<c >> > ha >> >> r> >> >> >,int> * >> >> - first {???} >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >> + std::_String_val<char,std::allocator<char> > {_Alval={...} } >> >> std::_String_val<char,std::allocator<char> > >> >> + _Bx {_Buf=0x00b827b4 "<<<<" _Ptr=0xabababab <Bad Ptr> } >> >> std::basic_string<char,std::char_traits<char>,std::allocator<char> >> >> >::_Bxty >> >> _Mysize 32380142 unsigned int >> >> _Myres 3529288 unsigned int >> >> second 3473784 int >> >> >> >> I have attached the piece of code as a file. The one that i have > got >> >> running >> >> on my machine (client example given on site - bit modified since on >> > the >> >> site >> >> it is outdated now). >> >> >> >> Thanks >> >> >> >> >> >> Bish, Tim wrote: >> >> > >> >> > So there are two different threads in the example code > (main.cpp), >> > each >> >> > of them creates a connection to the broker. They each try and >> > connect >> >> > to the broker on the url "tcp://127.0.0.1:61613", so you need to >> > ensure >> >> > that you have the broker running on you local machine and have > the >> > stomp >> >> > transport configured to be on port 61613, or you need to change > this >> > to >> >> > be whatever ip and port the broker is at. >> >> > >> >> > Sounds like it fails on this call in each thread: >> >> > >> >> > connection = connectionFactory->createConnection(); >> >> > >> >> > So you need to debug what is breaking, the exception stack trace >> > should >> >> > give you some clues. Either run in a console window or alter the >> > code >> >> > to grab this data and store it in a logfile or something. >> >> > >> >> > }catch ( CMSException& e ) { >> >> > e.printStackTrace(); >> >> > } >> >> > >> >> > You can use one of these methods from CMSException to do this >> >> > >> >> > /** >> >> > * Provides the stack trace for every point where >> >> > * this exception was caught, marked, and rethrown. >> >> > * @return vector containing stack trace strings >> >> > */ >> >> > virtual std::vector< std::pair< std::string, int> > >> >> > getStackTrace() const = 0; >> >> > >> >> > /** >> >> > * Prints the stack trace to the given output stream. >> >> > * @param stream the target output stream. >> >> > */ >> >> > virtual void printStackTrace( std::ostream& stream ) > const = >> > 0; >> >> > >> >> > >> >> > Worse comes to worse you can step through the TcpSocket::connect >> > method >> >> > in the debugger to find out where exactly its breaking. >> >> > >> >> >> >> >> >> If you look at the main function in the activemq-cpp client > given >> > on >> >> > our >> >> >> site >> >> >> I am just pasting it here now. It says. >> >> >> >> >> >> HelloWorldProducer producer( 1000 ); >> >> >> HelloWorldConsumer consumer( 5000 ); >> >> >> >> >> >> // Start the consumer thread. >> >> >> Thread consumerThread( &consumer ); >> >> >> consumerThread.start(); >> >> >> >> >> >> // Start the producer thread. >> >> >> Thread producerThread( &producer ); >> >> >> producerThread.start(); >> >> >> >> >> >> // Wait for the threads to complete. >> >> >> producerThread.join(); >> >> >> consumerThread.join(); >> >> >> >> >> >> When I debug the call goes to >> >> >> connection = connectionFactory->createConnection(); // inside >> >> >> HelloWorldConsumer.cpp and HelloWorldProducer.cpp >> >> >> >> >> >> It runs this piece of code in turn ... >> >> >> if( status < 0 ){ >> >> >> close(); >> >> >> throw SocketException( __FILE__, __LINE__, >> >> >> "Socket::connect - %s", ::strerror( errno ) ); >> >> >> } >> >> >> and throws the exception ... from the class tcpsocket.cpp >> >> >> >> >> >> >> >> >> >> >> >> Bish, Tim wrote: >> >> >> > >> >> >> >> >> >> >> >> The following piece of code in the class SocketFactory.cpp is >> >> > throwing >> >> >> >> exceptions .... >> >> >> >> BufferedSocket* socket = new > BufferedSocket(tcpSocket, >> >> >> >> inputBufferSize, outputBufferSize); >> >> >> >> socket->connect( host.c_str(), port ); >> >> >> >> >> >> >> >> it returns an invalid handle actually. I can see the call > coming >> > in >> >> >> > twice >> >> >> >> to >> >> >> >> this piece of code (producer and then the consumer ... both > are >> >> >> > threaded >> >> >> >> and >> >> >> >> do a join inside the main method). The second time the call >> > comes >> >> > in >> >> >> > it >> >> >> >> bombs. >> >> >> > >> >> >> > It shouldn't be calling the socket factory twice, especially > not >> >> > from >> >> >> > producer and consumer as they have nothing to do with the >> > sockets. >> >> >> > >> >> >> > What code are you trying to run? Example? >> >> >> > >> >> >> > If you run from a command window, what is the error that is >> > printed >> >> > out? >> >> >> > >> >> >> >> >> >> >> >> Cant understand why this is happening ... any ideas on what >> > could >> >> > be >> >> >> > the >> >> >> >> reason. >> >> >> >> I tried changing the port to 61614 for the broker and the > code >> > in >> >> > the >> >> >> >> client >> >> >> >> too ... did not work still ... same probs. >> >> >> >> >> >> >> >> Any hint would be really useful. >> >> >> >> -- >> >> >> >> View this message in context: > http://www.nabble.com/Sockets-not- >> >> >> >> > connecting-...-Invalid-handle-returned-tf2225941.html#a6168387 >> >> >> >> Sent from the ActiveMQ - User forum at Nabble.com. >> >> >> > >> >> >> > >> >> >> > >> >> >> >> >> >> -- >> >> >> View this message in context: http://www.nabble.com/Sockets-not- >> >> >> connecting-...-Invalid-handle-returned-tf2225941.html#a6171212 >> >> >> Sent from the ActiveMQ - User forum at Nabble.com. >> >> > >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: http://www.nabble.com/Sockets-not- >> >> connecting-...-Invalid-handle-returned-tf2225941.html#a6171774 >> >> Sent from the ActiveMQ - User forum at Nabble.com. >> > >> > >> > >> >> -- >> View this message in context: >> > http://www.nabble.com/dynamic_cast%3CIOTransport%3E---bombs.-Socks-not- >> connecting---Invalid-handle-tf2225941.html#a6172794 >> Sent from the ActiveMQ - User forum at Nabble.com. > > >
-- View this message in context: http://www.nabble.com/dynamic_cast%3CIOTransport%3E---bombs.-Socks-not-connecting---Invalid-handle-tf2225941.html#a6287897 Sent from the ActiveMQ - User forum at Nabble.com.