Skip to content

[🐛 Bug]: No connection could be made because the target machine actively refused it. #12114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Pandzioch opened this issue May 30, 2023 · 19 comments
Labels
I-defect Something is not working as intended J-issue-template Applied to issues not following the template, or missing information.

Comments

@Pandzioch
Copy link

What happened?

Hi dear developers.

So what I currently struggle with is a problem with C# Selenium with SocketException for ChromeDriver:

[09:30:07 ]   OpenQA.Selenium.WebDriverException : An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:23391/session/9e1b9a2ff8740b399050adc85714d15d/element. The exception message was: No connection could be made because the target machine actively refused it. (localhost:23391)
09:30:07     ----> System.Net.Http.HttpRequestException : No connection could be made because the target machine actively refused it. (localhost:23391)
[09:30:07 ]   ----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.

I've done some digging into this to actually find what's wrong.
Setup of the test is pretty straightforward, driver is being initialized with ChromeOptions:
"--start-maximized",
"--no-sandbox",
"--proxy-server='direct://'",
"--proxy-bypass-list=*",
This error occurs not only on CI/CD but my local machine also, what's worth mentioning is that for 60+ automated test cases, the error comes usually once per run.

Configuration setup looks like this:

  • ChromeDriver is being run from the package Selenium.WebDriver.ChromeDriver 113.0.5672.6300
  • Test are runnig by local chromedriver -> local test, no grid, docker, or cloud is being used.
  • CI/CD are running by the TeamCity agent, tests are being invoked by the usage of CommandLine with the command "dotnet test"
  • All packages are up to date
  • Chrome is up to date 113.0.5672.127 (64-bit)
  • .NET SDK 5.0.408
  • No proxy is set on the machine, on the server or the ChromeOptions
  • No VPN is set on any of the machines

I've tried all the solutions I could find by searching all across the internet by found no good.
What's even funnier, the downgrade from .NET 6.0 to .NET 5.0 project reduced this error by a lot (From 3-4 crashes to 1 or none)

How can we reproduce the issue?

I cannot share the source code of my repo due to the fact that it's unallowed by my contract but I'll try to do my best to describe it.

Crash of the webdriver happens mostly at random. There's no part of the code which triggers it at the same place currently. For example, if test consists of 20 steps to do, it can fail at 1 step, 15, or even the last one.

But what I think a hint may be is one NuGet Package & few methods used.
- I'm using DotNetSeleniumExtras.WaitHelpers package in ver 3.11.0 which catches most of the time StaleElementReference exceptions, one test was waiting for an angular overlay to drop with method ExpectedConditions.InvisibilityOfElementLocated which was crashing quite often, deleting it and using Thread.Sleep(XAmmountOfTime) solved the problem.
Same thing goes for the method ExpectedConditions.UrlContains("some string of an url")
- The method that also crashes from time to time is driver.Navigate().GoToUrl("some url")

The more tests are there, the higher chance of the error to occur

Relevant log output

09:30:07     Error Message:
09:30:07      OpenQA.Selenium.WebDriverException : An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:23391/session/9e1b9a2ff8740b399050adc85714d15d/element. The exception message was: No connection could be made because the target machine actively refused it. (localhost:23391)
09:30:07     ----> System.Net.Http.HttpRequestException : No connection could be made because the target machine actively refused it. (localhost:23391)
09:30:07     ----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.
09:30:07   TearDown : OpenQA.Selenium.WebDriverException : An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:23391/session/9e1b9a2ff8740b399050adc85714d15d/screenshot. The exception message was: No connection could be made because the target machine actively refused it. (localhost:23391)
09:30:07     ----> System.Net.Http.HttpRequestException : No connection could be made because the target machine actively refused it. (localhost:23391)
09:30:07     ----> System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.
09:30:07     Stack Trace:
09:30:07        at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
09:30:07      at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
09:30:07      at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
09:30:07      at OpenQA.Selenium.WebDriver.FindElement(String mechanism, String value)
09:30:07      at OpenQA.Selenium.By.<.ctor>b__11_0(ISearchContext context)
09:30:07      at OpenQA.Selenium.By.FindElement(ISearchContext context)
09:30:07      at OpenQA.Selenium.WebDriver.FindElement(By by)
09:30:07      at SeleniumExtras.WaitHelpers.ExpectedConditions.<>c__DisplayClass17_0.<InvisibilityOfElementLocated>b__0(IWebDriver driver)
09:30:07      at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition, CancellationToken token)
09:30:07      at OpenQA.Selenium.Support.UI.DefaultWait`1.Until[TResult](Func`2 condition)
09:30:07      at Eagle.Framework.Models.E2E.Wait.Until(Func`2 condition) in C:\BuildAgent\work\d20cd7016e022376\Eagle.Framework\Models\E2E\Wait.cs:line 30
09:30:07      at Eagle.Framework.PageObjects.mCalendar.mCalendar.SaveConference() in C:\BuildAgent\work\d20cd7016e022376\Eagle.Framework\PageObjects\mCalendar\mCalendar.cs:line 303
09:30:07      at Eagle.E2E.Test.StepDefinitions.mCalendarStepDefinitions.ThenKonferencjaZostajeZapisana() in C:\BuildAgent\work\d20cd7016e022376\Eagle.E2E.Test\StepDefinitions\mCalendarStepDefinitions.cs:line 302
09:30:07      at TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
09:30:07      at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStepMatch(BindingMatch match, Object[] arguments, TimeSpan& duration)
09:30:07      at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance)
09:30:07      at TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnAfterLastStep()
09:30:07      at TechTalk.SpecFlow.TestRunner.CollectScenarioErrors()
09:30:07      at Eagle.E2E.Test.Features.MKalendarz_KonferencjeFeature.ScenarioCleanup()
09:30:07      at Eagle.E2E.Test.Features.MKalendarz_KonferencjeFeature.Sale_Edycja() in C:\BuildAgent\work\d20cd7016e022376\Eagle.E2E.Test\Features\mCalendarConferences.feature:line 178
09:30:07   --HttpRequestException

Operating System

Windows 10, Windows Server 2016 Standard

Selenium version

C# Selenium.WebDriver 4.9.1, NUnit 3.13.3, NUnit3TestAdapter 4.4.2

What are the browser(s) and version(s) where you see this issue?

GoogleChrome 113.0.5672.127 (64-bit)

What are the browser driver(s) and version(s) where you see this issue?

Selenium.WebDriver.ChromeDriver 113.0.5672.6300

Are you using Selenium Grid?

No

@Pandzioch Pandzioch added I-defect Something is not working as intended A-needs-triaging A Selenium member will evaluate this soon! labels May 30, 2023
@github-actions
Copy link

@Pandzioch, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol diemol added J-issue-template Applied to issues not following the template, or missing information. and removed A-needs-triaging A Selenium member will evaluate this soon! labels May 30, 2023
@titusfortner
Copy link
Member

titusfortner commented May 30, 2023

Why are you setting these if there is no proxy on the machine?

"--proxy-server='direct://'",
"--proxy-bypass-list=*",

The only supported means in Selenium to pass proxy information is with the Proxy property in the options class.

Further, DotNetSeleniumExtras is explicitly unmaintained an unsupported, so if you think that is causing a problem, the recommendation is to create your own anonymous functions.

Finally, in order to consider this issue a bug, we need a minimal reproducible example

@github-actions
Copy link

Hi, @Pandzioch.
Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

@Pandzioch
Copy link
Author

@titusfortner
"--proxy-server='direct://'", "--proxy-bypass-list=*",
Those options were set as a part of terminal "Solution" in the meanwhile as I was verifying the proxy setup for machines. It's now removed (It didn't change behavior in any way).

I took my time to work with those waiting methods and removed DotNetSeleniumExtras NuGet (this also goes for SeleniumExtras.WaitHelpers).
^
And that's actually a solution to this problem. I really don't know why, because it was only checking the IWebElement status and capturing NoSuchElement & Staleness Exceptions but the error description is pointing to:
System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.
So either the Driver got busy or stuck itself on something.

I wish I could give You a straight copy-paste of the code, but as I've mentioned before that cannot be done.
Will try to reproduce it on my private machine to clarify the process.

@titusfortner
Copy link
Member

So moving to anonymous functions fixed your problem?

If you don't still have an problem, I wouldn't spend time trying to figure out why you had it. We can close this issue and have another example of why people should avoid expected conditions classes.

@Pandzioch
Copy link
Author

Well, it didn't solve my problem per se.
This method below makes the problem
image

@titusfortner
Copy link
Member

So that method sometimes throws a socket exception.... I can't remember if that error is essentially a kind of timeout.

Are you running multiple tests in parallel? Is the system under test overtaxed?

@Pandzioch
Copy link
Author

Tests are running as nonparallel due to the usage of SpecFlow as a BDD overlay. At the moment of the run, I was the only person using it at the time.

I've changed the method for invisibility of the element to:

       public static Func<IWebDriver, bool> InvisibilityOf(By locator) => delegate (IWebDriver driver)
        {
            return driver.FindElements(locator).Count == 0;
        };

Which seems to be working fine (at least for now). But I kinda don't understand the message here because:
The exception message was: No connection could be made because the target machine actively refused it.
It seems like a network issue, rather than a timeout. Maybe You have some more insight into this kind of an exception

@titusfortner
Copy link
Member

Yeah, this seems like some kind of network issue. The question is whether it is immediately throwing the error or if there is some time it is waiting and then throwing the error. If there is a time difference, is the problem that the difference isn't enough time given, or would it always fail, regardless. I'm not sure how to debug this one more.

@Pandzioch
Copy link
Author

Based on my personal experience, for most of the runs, the issue occurred on a slight timeout, around 3-4 seconds. It looks like waiting and then throwing an error.
I found one case in which the test got stuck for about an hour (teamcity agent closed the run due to the timeout settings) in this method.
From my approach, we can close this thread, because well, it's even hard to pull off without giving a set of as many automated tests possible with the usage of that particular library. Maybe there should be a prevention mechanism for this, I really don't know.

Anyway, I really appreciate Your time Titus, thanks for looking at it.
Maybe selenium documentation page should have like one big red banner with "Don't use nuget packages with waits" 😆

@titusfortner
Copy link
Member

We're going to be talking more about this going forward. I'm hoping for Selenium 5 to take the approach that .NET did and move some of these helper libraries outside of Selenium proper for all the languages.

@NCLnclNCL
Copy link

We're going to be talking more about this going forward. I'm hoping for Selenium 5 to take the approach that .NET did and move some of these helper libraries outside of Selenium proper for all the languages.

errors with me
No connection could be made because the target machine actively refused it. (localhost:52847)
No connection could be made because the target machine actively refused it. (localhost:52848)
The request was canceled due to the configured HttpClient.Timeout of 5 seconds elapsing.
Unhandled exception. System.AggregateException: One or more errors occurred. (An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:52847/session. The exception message was: An error occurred while sending the request.) (An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:52848/session. The exception message was: An error occurred while sending the request.) (An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:52849/session. The exception message was: An error occurred while sending the request.)
---> OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:52847/session. The exception message was: An error occurred while sending the request.
---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities) at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout) at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) at Elementhelpername.Helper..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan timeout, Int32 tempI) in D:\dotnetcore\sele local\lib\helper.cs:line 6 at libopen.Open.OpenGpmWithStartProcess(Int32 tempI, Int32 luong, LaunchOptions options, String user_data) in D:\dotnetcore\sele local\lib\openbrowser.cs:line 120 at selenium.Start.start(Int32 tempI, Int32 luong) in D:\dotnetcore\sele local\selenium.cs:line 57 at multithread.Multi.<>c__DisplayClass0_0.<luong>b__0() in D:\dotnetcore\sele local\lib\multithread.cs:line 23 at System.Threading.Tasks.Task.InnerInvoke() at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.WaitAllCore(Task[] tasks, Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.WaitAll(Task[] tasks) at multithread.Multi.luong(Int32 threads, Int32 times, Int32 profile) in D:\dotnetcore\sele local\lib\multithread.cs:line 27 at seletest.Program.Main(String[] args) in D:\dotnetcore\sele local\Program.cs:line 41 ---> (Inner Exception #1) OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:52848/session. The exception message was: An error occurred while sending the request. ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.. ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host. --- End of inner exception stack trace --- at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken) at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token) at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async) at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo) at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) --- End of inner exception stack trace --- at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at Elementhelpername.Helper..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan timeout, Int32 tempI) in D:\dotnetcore\sele local\lib\helper.cs:line 6
at libopen.Open.OpenGpmWithStartProcess(Int32 tempI, Int32 luong, LaunchOptions options, String user_data) in D:\dotnetcore\sele local\lib\openbrowser.cs:line 120
at selenium.Start.start(Int32 tempI, Int32 luong) in D:\dotnetcore\sele local\selenium.cs:line 57
at multithread.Multi.<>c__DisplayClass0_0.b__0() in D:\dotnetcore\sele local\lib\multithread.cs:line 23
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)<---

---> (Inner Exception #2) OpenQA.Selenium.WebDriverException: An unknown exception was encountered sending an HTTP request to the remote WebDriver server for URL http://localhost:52849/session. The exception message was: An error occurred while sending the request.
---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.
--- End of inner exception stack trace ---
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource<System.Int32>.GetResult(Int16 token)
at System.Net.Http.HttpConnection.InitialFillAsync(Boolean async)
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.HttpConnection.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.WebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.WebDriver..ctor(ICommandExecutor executor, ICapabilities capabilities)
at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ChromiumDriverService service, ChromiumOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at Elementhelpername.Helper..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan timeout, Int32 tempI) in D:\dotnetcore\sele local\lib\helper.cs:line 6
at libopen.Open.OpenGpmWithStartProcess(Int32 tempI, Int32 luong, LaunchOptions options, String user_data) in D:\dotnetcore\sele local\lib\openbrowser.cs:line 120
at selenium.Start.start(Int32 tempI, Int32 luong) in D:\dotnetcore\sele local\selenium.cs:line 57
at multithread.Multi.<>c__DisplayClass0_0.b__0() in D:\dotnetcore\sele local\lib\multithread.cs:line 23
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)<---

@titusfortner
Copy link
Member

This could be a session trying to access a driver that was closed by a previous session. I'd check to see how things are running in parallel, or if there are any proxy issues. Make sure you are using latest Selenium. Not sure what else to suggest.

@NCLnclNCL
Copy link

NCLnclNCL commented Aug 25, 2023

This could be a session trying to access a driver that was closed by a previous session. I'd check to see how things are running in parallel, or if there are any proxy issues. Make sure you are using latest Selenium. Not sure what else to suggest.

Yes, i use newest, with connect remote debug port not direct open from selenium, i dont use proxy, error realease after 30- 40 times run,i reused the port after each session (port is calculated by thread, i close the browser then open a new one), i think this might be the problem

@NCLnclNCL
Copy link

This could be a session trying to access a driver that was closed by a previous session. I'd check to see how things are running in parallel, or if there are any proxy issues. Make sure you are using latest Selenium. Not sure what else to suggest.

The request was canceled due to the configured HttpClient.Timeout of 5 seconds elapsing

is there any way to increase this timeout, i see default httpclient is 100s

@titusfortner
Copy link
Member

If the driver were running on that port, the connection would happen in milliseconds. That timeout is not the problem.

@titusfortner
Copy link
Member

Note: this is the connection timeout not the read timeout

@Pandzioch
Copy link
Author

This could be a session trying to access a driver that was closed by a previous session. I'd check to see how things are running in parallel, or if there are any proxy issues. Make sure you are using latest Selenium. Not sure what else to suggest.

The request was canceled due to the configured HttpClient.Timeout of 5 seconds elapsing

is there any way to increase this timeout, i see default httpclient is 100s

Well, I'll try to respond due to some similarities to my own problem.
So basically, while I was running selenium on a specific WindowsServer that someone previously owned( and quit the job without leaving any documentation or any insight), my tests were shutting down randomly.
Why did it happen? As it turns out, someone created a Task in windows TaskScheduler, to run at 7-8-9AM (3 in total) via Powershell to start tests with ChromeDriver, then after all the tests we're colliding with one another, as the end of the job, there was a task to shutdown all driver.exe processes.

I discovered it after a while after posting this thread.
Maybe check for any jobs/services/powershells/task etc on the machine that Your tests are running on.
It could be even the same session that was not shutdown after debugging set on a specific port that takes this port until the task is completed.

Copy link

github-actions bot commented Dec 7, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
I-defect Something is not working as intended J-issue-template Applied to issues not following the template, or missing information.
Projects
None yet
Development

No branches or pull requests

4 participants