API says it can't send while waiting on DNS

Options

I'm trying to do a pub/sub tutorial, both publishing 1 message and subscribing to the queue. The original JS code as Solace created on Github. I'm trying to Typescript-ify the code and now it says

OperationError: Cannot perform operation SEND while in state WaitingForDNS

PING resolves the host URL to an IP address, so at the very least, this message is misleading.

This happens on a session.send(solaceMessage);

Answers

  • benprachtrsi
    benprachtrsi Member Posts: 6
    Options

    I'm not sure how to report what I believe to be a defect. The API docs at https://docs.solace.com/API-Developer-Online-Ref-Documentation/nodejs/solace.Session.html#connect suggest that if there was an error, it throws a solace.OperationError exception. I have my call to connect() inside a try/catch block and the catch is never thrown.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 500 admin
    Options

    Hey @benprachtrsi you mentioned you only started getting this issue when you attempted to typescript-ify the sample. can you share snippet on your approach? I am not familiar with a waitingForDNS error but have raised this issue internally to see if there is anything im missing.

    And another clarification question, are you running this against a local broker or a solace cloud instance?

  • benprachtrsi
    benprachtrsi Member Posts: 6
    Options

    Hi @Tamimi, thanks for your reply. I'm running against a Solace cloud instance.

    I've stepped through the code and have come to believe it's happening when the connect() occurs, though it does not throw any exceptions.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 500 admin
    Options

    I believe what is happening here is that session.Connect() is a non blocking method and there was no wait for session connection to complete before attempting to send a message. As you can see in the javascript API docs, there is a note stating:

    Note: Before the session's state transitions to 'connected', a client application cannot use the session; any attempt to call functions will throw solace.OperationError.

    So you would only want to return the session instance when the UP_NOTICE session event code is fired. You would get an OperationError exception if you attempt an operation on the session before SessionEventCode.UP_NOTICE

    Can you attempt to register an event listener for the UP_NOTICE event and execute your publish command after that?

  • giri
    giri Member, Administrator, Employee Posts: 110 admin
    Options

    Hi @benprachtrsi, did that work for you? The connection is ready for send/receive activities only after the UP_NOTICE comes through on the event listener.

  • benprachtrsi
    benprachtrsi Member Posts: 6
    Options

    That almost helped. The best it was able to do was make a connection and stall for no obvious reason. So, I added logs to every reject side of a promise and I'm now listening to every available session event handler. It now comes back right away with no obvious error and no sign of having made a connection. I should point out that I'm looking at the session panels for the service and was able to see my IP address when it did make the connection. I believe it is back to WaitingForDNS based on previous experience. I think your advice is accurate, but I cannot get it to wait, just wait, for the connection, no matter how I structure the promises.

  • giri
    giri Member, Administrator, Employee Posts: 110 admin
    Options

    Thanks for sharing the code sample; I have sent a message in this regard. Let us know if that helps.

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 500 admin
    Options

    I want to point out as well that you can turn on further logging from the solace module by setting the log level to debug

    solace.SolclientFactory.setLogLevel(solace.LogLevel.DEBUG);
    


  • benprachtrsi
    benprachtrsi Member Posts: 6
    Options

    @Tamimi I've tried the increased logging. In a limited circumstance, I was able to see one of the Solace cloud's DNS name being resolved to an IP address. It was helpful to confirm it actually reached that area of the code. However, I think much of it would be more helpful to the Solace team than myself :)