Get remote host/node name from Selenium Grid Hub on error

536 views
Skip to first unread message

Kendall Schmidt

unread,
Mar 8, 2017, 1:45:18 PM3/8/17
to Selenium Developers
Occasionally when running tests in a Selenium Grid, some tests get the following error:

org.openqa.selenium.WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:  <blah>...

I don't really care about this error, per say, but I do want to know what 'node' the hub was trying to communicate with when this error happens.

I don't necessarily need the 'node' name in the stack trace. I'd be perfectly fine if it was logged somewhere (console?) that I can then direct to my logs via log4j/logback.

Currently I have my logback root level=INFO.  Would it be as simple as changing this to something else like DEBUG?

Steven Zaluk

unread,
Mar 8, 2017, 7:27:47 PM3/8/17
to selenium-...@googlegroups.com
You can call the following endpoint once the test is initialized:

http://[grid]:4444/grid/api/testsession?session=[sessionid]

This returns a JSON with info on the test session, including which node the test is running on.  I am not sure if this changed in Selenium Grid 3.x.x or not.  I also don't know of anyway to do that if the hub can't establish a connection to the node at all.

--Steve

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-developers/9a2ca799-6a45-4a4f-b6e8-f9eafe969b5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kendall Schmidt

unread,
Mar 8, 2017, 7:51:19 PM3/8/17
to Selenium Developers
Steve,

Thanks for this info but I think in this case the key issue is that the test didn't successfully initialized, therefore, I have no access to the sessionId to hit the endpoint.

The exception is being thrown during the creation of the RemoteWebDriver (i.e. new RemoteWebDriver(hubUrl, capabilities) call) and the message is relative to the webdriver running on the remote node, hence the 'Unable to connect to host 127.0.0.1' - i.e. localhost.

Ultimately, development teams want to know what host/node in the grid threw the exception to investigate the root cause of the error. Getting back just 127.0.0.1/localhost from the remote webdriver doesn't help.

Am I missing something in your response?

Thanks,
Kendall

Bill Ross

unread,
Mar 8, 2017, 8:12:41 PM3/8/17
to selenium-...@googlegroups.com

Kendall,

> http://[grid]:4444/grid/api/testsession?session=[sessionid]

This notation implies that you put your grid server's address where indicated, likewise with the session id that your test hopefully has given you, and hit that endpoint with your browser to see the info you want.

Bill
--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-developers/711578d7-26ed-41bf-9ce8-3b906b7c0914%40googlegroups.com.

Steven Zaluk

unread,
Mar 8, 2017, 8:49:47 PM3/8/17
to selenium-...@googlegroups.com
Hey Kendall,

You are correct - if the hub can't establish a connection to the node at all then this method won't work.  I am not sure how to pull that data back in a situation like that.

--Steve

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-developers/576b9ed2-9e15-3512-b728-6fda2e87eab0%40cgl.ucsf.edu.

Bill Ross

unread,
Mar 8, 2017, 9:09:54 PM3/8/17
to selenium-...@googlegroups.com

> the key issue is that the test didn't successfully initialized,

Oops, my mistake.

Bill

⇜Krishnan Mahadevan⇝

unread,
Mar 8, 2017, 10:22:14 PM3/8/17
to selenium-...@googlegroups.com
Kendall,

In normal terms you should be able to use the Grid APIs (I built a library called Talk2Grid which makes it more easy) to get details about the node to which the test was routed to.

On a side note, the Grid APIs are all set to go through a major overhaul and you should see a much more RESTish APIs once this PR gets merged.

But in this case, the new session itself has conked. So you wouldn't be able to get information.
The lack of a proper error message being rendered back to you could also be due to the fact that Selenium now prunes through the error message and only if it finds a "Session not created" does it pack the actual reason.

I recently raised a PR for fixing this so that this error bubbles up (just as it used to earlier). This fix should be part of the upcoming Selenium 3.3.0 release. 

So for now, in order to figure out what went wrong with a failed new session, the only option is to look at the console logs.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-developers/73f229fe-2080-f2fb-9811-14af257b760c%40cgl.ucsf.edu.

Kendall Schmidt

unread,
Mar 8, 2017, 10:49:36 PM3/8/17
to Selenium Developers
Kishnan,

I've been watching your pull requests for your new grid hub api's.  I wrote my own about a year ago to get info about the hub queue that I needed to use in conjunction with AWS AutoScaling.

As for Selenium pruning through the error messages and packing the actual reason only if it finds a "Session not created", it seems that a reasonable and possible simple change would be to include the remote host node's hostname and/or IP address in the current message.

Something like:

org.openqa.selenium.WebDriverException: Unable to connect to host <hostname|ip_address> on port 7055 after 45000 ms. Firefox console output:  <blah>...

instead of 'Unable to connect to host 127.0.0.1' ...

I assume this exception is being thrown from the remote host and therefore can obtain it's own hostname and add it to the message.

Maybe?

⇜Krishnan Mahadevan⇝

unread,
Mar 9, 2017, 12:54:50 AM3/9/17
to selenium-...@googlegroups.com
Kendall,

As for Selenium pruning through the error messages and packing the actual reason only if it finds a "Session not created", it seems that a reasonable and possible simple change would be to include the remote host node's hostname and/or IP address in the current message.

This sounds like a valid request and should be doable. Let me see if I can get to this over the weekend if no one else beats me to it before that :)


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsubscribe...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Selenium Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-developers+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages