Using DevTools features with Selenium Grid on Docker - docker

I managed to work with DevTools features in Selenium 4 locally, but when I tried to use it on Selenium Grid, it didn't work.
In order to investigate it, I installed a local grid with one Chrome node using docker-compose and I got the same error:
OpenQA.Selenium.WebDriverException : Unexpected error creating WebSocket DevTools session.
----> System.Net.WebSockets.WebSocketException : Unable to connect to the remote server
----> System.Net.Http.HttpRequestException : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (172.18.0.3:4444)
----> System.Net.Sockets.SocketException : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Where 172.18.0.3 is the private IP of chrome-node container.
I guess that the main reason is that I don't have access to that IP from the host, and that's probably a docker configuration matter, on which I'm not an expert. But that wasn't the only problem.
Using the debugger, I was able to track that the driver tries to use this address due to the following capability that is returned from the driver after creation: "se:cdp": "ws://172.18.0.3:4444/session/2c519f679e1060cdc926ca74e63e222f/se/cdp". I then tweaked this value (in the debugger, before trying to create the connection to the DevTools protocol) to use localhost instead of the private IP, and then I got the following error: IOException: The response ended prematurely..
What do I need to do in order to use the DevTools features of Selenium through Selenium Grid (and docker)?

Adding - SE_NODE_GRID_URL=http://localhost:4444/ environment to the "chrome" container in the docker-compose yaml file solves the problem.
If you want to access the grid from outside of the host, instead of localhost write the IP or name of the machine.

Related

Connect ASP.NET Core container to remote SQL Server

I am trying to connect my ASP.NET Core application to a remote SQL Server.
The application is deployed using IIS WScore 2016 image. When I run the application on my host, it's working, but in the container using this connection string :
Data Source=xx.xxx.xx.xx,1433;Initial Catalog=somedb;User Id=xxxxxx;Password=xxxxx;
or:
Server=xx.xx.xx.xx,PORT_NB;Database=DATABASE;User Id=USER;Password=PASSWORD
But no luck - I am using the default Docker network.
The error is like this:
Error: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)
Notes:
The server is allowing the remote connection
All the connection strings are tested and can connect to the remote SQL Server from the application that runs on the host
I have read the Docker documentation and they mentioned the IP forwarding but the example was on linux containers and I did not find any help about connecting the Windows containers to a remote SQL Server
Question
My concrete question is how to expose the container to the outside world and I can connection my container to the other remote services like a remote SQL Server?
Should I use host network or bridge with the IP forwarding?
Any help? Thanks
I changed the connection string to this :
"ConnectionString": "Server=xx.xxx.xx.xx\\MSSQLSERVER,1433;Initial Catalog=Dbname;User Id=username;Password=xxxxxxx;"
then i restarted the AppPoll and it worked
What is the current network you're using for this container? If you used the default network, then you're using Network Address Translation (NAT). What that means is that you're using the host IP address to connect to the external network. So, your problem most likely is that the SQL Server is rejecting the connection from the IP of the container host.
The alternative on Windows is to use a different network drive. There are many options and I'd recommend you look at the option that better suits your needs: https://cda.ms/4nP
I had the same error, try removing the port from the connection string as follows:
"ConnectionString": "Server=ContainerName;Initial Catalog=Dbname;User Id=username;Password=xxxxxxx;"

How do I connect an Ado.Net client to my NuoDB on Linux Docker

I created the 3 necessary containers for NuoDB using the NuoDB instructions.
My Docker environment runs on a virtual Ubuntu Linux environment (VMware).
Afterwards I tried to access the database using a console application (C# .Net Framework 4.8) and the Ado.Net technology. For this I used the Nuget "NuoDb.Data.Client" from Nuget.org.
Unfortunately the connection does not work.
If I choose port 8888, my thread disappears to infinity when I open the connection.
For this reason I tried to open the port 48004 to get to the admin container.
On this way I get an error message.
"System.IO.IOException: A connection attempt failed because the remote peer did not respond properly after a certain period of time, or the established connection was faulty because the connected host did not respond 172.18.0.4:48006, 172.18.0.4"
Interestingly, if I specify a wrong database name, it throws an error:
No suitable transaction engine found for database.
This tells me that it connects to the admin container.
Does anyone have any idea what I am doing wrong?
The connection works when I establish a connection with the tool "dbvisualizer".
This tool accesses the transaction engine directly. For this reason I have opened the port 48006 in the corresponding container.
But even with these settings it does not work with my console application.
Thanks in advance.
Port 8888 is the REST port that you would use from the administration tool such as nuocmd: it allows you to start/stop engines and perform other administrative commands. You would not use this port for SQL clients (as you discovered). The correct port to use for SQL clients is 48004.
Port 48004 allows a SQL client to connect to a "load balancer" facility that will redirect it to one of the running TEs. It's not the case that the SQL traffic is routed through this load balancer: instead, the load balancer replies to the client with the address/port of one of the TEs then the client will disconnect from the load balancer and re-connect directly to the TE at that address/port. For this reason, all the ports that TEs are listening on must also be open to the client, not just 48004.
You did suggest you opened these ports but it's not clear from your post whether you followed all the instructions on the doc page you listed. In particular, were you able to connect to the database using the nuosql command line tool as described here? I strongly recommend that you ensure that simple access like this works correctly, before you attempt to try more sophisticated client access such as using Ado.Net.

Unable to connect to Neo4J/ONgDB Browser when port forwarding

I am running the ONgDB container as per their Docker run command.
I have tested this locally on my laptop and it worked before, I was able to navigate to the graph browser and log in.
Now I am running this Graph in a server.
I did port forwarding to my laptop successfully, and am able to see ONgDB Browser in my laptop. However I am unable to log in, I get the error:
ServiceUnavailable: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons inc...
I found Neo4J article on how to resolve it.
I entered the ONgDB container filesystem and opened the .conf file, but there was no line to uncomment.
I tried to add the suggested line dbms.connector.bolt.address=0.0.0.0:7687 but it does not work as well.
How can I enable ONgDB Docker container for remote access?
I figured out the problem, in Neo4J/ONgDB browser, it fills the database host with localhost by default.
You just have to fill it in with the server's IP there and it works.
Also, you can connect using a desktop Neo4J/ONgDB browser to a remote graph, its just like a database (RDBMS) where you can connect to it from a client running locally.

Docker and EF Core: No connection could be made because the target machine actively refused it

I try to connect to the host's SQL Server Instance (SQL 2017 on Windows 10) from a Docker container (running a .NET Core app with EF Core).
The SQL Server is configured to listen on the default port 1433 (no dynamic ports are used) and to allow remote connections (TCP/IP). I also set up an inbound rule for the firewall and the given port (I also tried with firewall off). I can connect to the database and run SQL queries with the sqlcmd command line tool running in a Docker container.
This is the connection string I'm using:
Server=tcp:host.docker.internal,1433;Database=AuthIdentity;Trusted_Connection=False;User Id=sa;Password=xxxx;MultipleActiveResultSets=True;
When I run my container I get the following error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 0 - No connection could be made because the target
machine actively refused it.)
When I turn off my firewall (even if there is a firewall rule for the SQL port) I'll end up getting:
SqlException: A network-related or instance-specific error occurred
while establishing a connection to SQL Server. The server was not
found or was not accessible. Verify that the instance name is correct
and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 0 - A connection attempt failed
because the connected party did not properly respond after a period of
time, or established connection failed because connected host has
failed to respond.)
When I start the same program as IIS application (without any other changes) it's running perfectly fine and it's connecting as expected.
The error occurs when the program executes the first SQL operations (in this case it's the database migration - this is within the program startup)
serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>().Database.Migrate();
EDIT: A simpler setup in another API project (both will raise the same errors as described above):
[HttpGet("setup")]
[AllowAnonymous]
public IActionResult Setup()
{
try
{
this._context.Database.Migrate();
return Ok("success");
}
catch (Exception e)
{
return Json(e);
}
}
[HttpGet("get")]
[AllowAnonymous]
public List<ApplicationUser> Get()
{
return this._context.Users.ToList();
}
EDIT 2: As suggested from #Mohsin Mehmood I run a test with the NAT address (from ipconfig /all) and I can successfully connect with the given IP (172.28.112.1) to the SQL server. I also checked what I receive when running docker run --rm -i microsoft/nanoserver:1709 ping host.docker.internal and it gets me 62.138.239.45 as the address.
Never the less I would appreciate a solution which is not using a "hard-coded" IP address but a DNS like host.docker.internal. I'm also not sure why both IP addresses are different (172.28.112.1 vs. 62.138.239.45) and why the container can't get the correct address from the DNS.
What are the things I'm missing? How can this problem be solved? I already searched Google and SO without any working answer.
I suggest to try Windows 10 host server IP address instead of domain host.docker.internal to confirm that issue is related to DNS resolution. Also, I found that there is still an open issue related to internal host dns resolution in windows containers

Can't connect remotely to my Neo4j database

I have a Neo4j database on my desktop computer that I would like to access remotely. I'm not very knowledgeable about servers/networking, but here's a list of things I've done to try to get it working:
Uncommented the dbms.connectors.default_listen_address=0.0.0.0 line in the settings, as well as dbms.connector.http.listen_address=:7474 and dbms.connector.https.listen_address=:7473
Set up a TCP/UDP port forward on my router mapping 30408 to 7473.
Reserved a static IP for my desktop (the same one that appears in the port forward).
Defined incoming firewall exceptions on my desktop for ports 7474, 7473, and 30408 for both TCP and UDP (I'm guessing the 30408 one doesn't matter, but I've been trying everything).
When I try to connect through Chrome with {public_ip}:30408, it gives ERR_EMPTY_RESPONSE (Firefox just says "The connection was reset").
I am able to successfully connect to the neo4j browser on my local network with {local_ip}:7474.
Edit: Should I look into trying to do this with SSH? I still don't know what is going wrong in the first place.

Resources