I have a Visual Studio 2008 Team System C# solution running on my Windows 7 64bit box, and it has about 200 Selenium tests.
Until an hour ago most of the tests were okay, but suddenly none of the tests will run. They all give the same error:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:4444.
I'm using selenium-server-standalone-2.45.0, installed in ...\Program Files (x86)\selenium-remote-control-2.45.0
This has happened out of the blue, and I can't fathom out what might have changed. The code where the error is generated (this has been unchanged for years and usually works quite reliably) is:
public static ISelenium CreateDefaultSelenium()
{
string browser = ConfigurationManager.AppSettings["UnitTestBrowserString"];
if (browser == null)
browser = "*iexplore";
ISelenium selenium = new DefaultSelenium("localhost", 4444, browser, "http://localhost/");
return selenium;
}
public static void Start(this ISelenium selenium, int tries)
{
// Start the browser with a new Selenium session. Catch any WebException (eg socket refused) and retry a few times.
bool started;
int tryCount = 0;
do
{
tryCount++;
try
{
selenium.Start(); //<--this fails with the WebException
started = true;
}
catch (System.Net.WebException)
{
started = false;
if (tryCount >= tries)
throw;
}
} while (!started);
}
//start selenium at the beginning of each test:
ISelenium selenium = CreateDefaultSelenium();
selenium.Start(5);
and it throws a WebException with the error message I copied above.
I've ensured my local Windows firewall has port 4444 open for inwards TCP and UDP (it isn't usually), but that hasn't cured the problem. If I run the web application myself, it works fine so IIS is okay, although VS is using its own webserver. Rebooting has made no improvement.
Can anyone suggest what might have changed to cause this? I am at a loss as to where to turn next.
TIA
Okay, it turned out that amongst the Selenium log files there was a collection of lock files (selenium.log.1.lck etc). Deleting these immediately cured the problem.
Any chance of the Selenium team adding this gem to the Selenium documentation? It has taken me days to stumble onto this solution!
Related
Over the past 18 months I have successfully developed an air quality monitoring system that controls an air purifier in my home, I am also using the Blynk platform to monitor and control remotely. Now, I want to migrate this project over to my own website, I have my own website and using standard HTTP commands I now log all the data into a database and graph the data over time.
I want full bi-directional data transfer i.e log data from remote sensors to website and control air purifier settings from website to air purifier. It would appear that one way to do this is by using a webSocket, I have a shared hosting plan with BlueHost so I have now purchased a dedicated ip address and an opened port for both incoming and outgoing connections.
After many hours of trawling the internet and many forums I am struggling to find an example of how to implement this webSocket system. All the examples seem to be for local servers and I cannot find anything that shows what needs to be included in the website end to get a successful connection.
If anyone has any experience with webSockets and BlueHost I would appreciate your help.
Richard
It is relying on what language are you going to use for backend to implement websocket connection no matter what hosting you choosed.
If you want to use PHP, it is pretty straightforward because there is no specific overlay ontop of websocket protocol in this case unlike socketio for NodeJS and others. This example may help you to start which I found in 5 minutes of searching. If you are confused about websocket implementation at all it's a good idea to try websocket for web at first by simple example.
If you want to use NodeJS you may probably want to use existing library something like this.
In case of Java there is SockJS usually used out of the box as standard library for client. So you have to find or make something similar but for C++ if you have enough skills or try to configure simple websocket connection as for PHP.
I have used Firebase library for bidirectional communication with ESP8266, because it is pretty simple and free for small projects. The main benefit of this approach that you don't need to maintain your backend, it just works 24/7 since you've configured connection and business logic. Probably this is what are you looking for. Also you can host static pages on Firebase cloud as well if you need kind of admin interface. Heroku hosting is also free for tiny projects.
#mr.boris
Many thanks for your quick reply and help.
I have been using several examples like your first suggested example, the problem always is that I cannot get passed the "handshake" routine.
Arduino IDE serial monitor output
Connecting to XXXXXXXX
.
WiFi connected
IP address:
192.168.0.110
Connected
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Waiting...
Handshake failed.
The port that BlueHost have opened is 1025 could this be the problem?
I have cut done the esp8266 program to the bare minimum
#include <ESP8266WiFi.h>
#include <WebSocketClient.h>
char* WEBSOCKET_PATH = "/webSocket_02.php";
char* WEBSOCKET_HOST = "xxx.com";
char* WIFI_SSID = "xxxxxxxxx";
char* WIFI_PASSWORD = "xxxxxxxxxx";
WebSocketClient webSocketClient;
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(WIFI_SSID);
WiFi.mode(WIFI_STA);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(5000);
if (client.connect(WEBSOCKET_HOST,80)) {
Serial.println("Connected");
}
else {
Serial.println("Connection failed.");
}
webSocketClient.path = WEBSOCKET_PATH;
webSocketClient.host = WEBSOCKET_HOST;
if (webSocketClient.handshake(client)) {
Serial.println("Handshake successful");
}
else {
Serial.println("Handshake failed.");
}
}
void loop() {
}
The port number here is 80 (WEBSOCKET_HOST,80), if I change it to 1025 I get no result at all.
I've been trying to fix a really annoying problem in a Java Web project. We use Spring (3.1.4) with webflow (2.3.1), running over Wildfly 11.0 on a Amazon Server. In short, the remote server is giving 504 - Timeout error for a task that the local environment doesn't.
An specific page exports a .xls report which internally do a lot of work in consulting database and other aplication REST APIs. This functionality is inside a ManagedBean like so:
#org.springframework.stereotype.Component
#Scope(value = "request")
public class ReportMB {
...
public void export(){
try{
// code goes here
// generates HttpServletResponse containing the report file
} catch (...) {...}
}
This report is successfully generated in my development machine even if I choose too many data to be included, although it takes up to few minutes to complete. When it runs on the remote server, with the same Wildfly version and project deployment, we get 504 - Timeout with far less data in under 100 seconds.
I've already examined the logs and even debugged the proccess (locally), and both environments (local and remote) do not thow any exception. Do you have any clue why the local server waits until the function finishes and the file gets ready but the remote server doesn't, or at least do you have an idea on how to increase the Wildfly/Spring timeout tolerance for this request? (I have seen many examples of changing the deployment timeout but nothing related to the request timeout)
Thank you in advance.
The 504 will be being created by the loadbalancer not the app server. Increase the timeout on the loadbalancer
Running Postgresql 9.5 on a windows server 2012 R2 in Azure
While running some loadtests on my application, I get errors on not being able to connect to the postgres server. In the logs of postgres I get the following message:
could not receive data from client: No connection could be made
because the target machine actively refused it.
This only happens when the loadtest goes to the next scenario, hitting a different part of the code. So new connections to the database are required. But after 10-20 seconds the rest of the scenario works flawlessly without hitting any other hiccups. So the problem seems to be the tcp connections. (My code retries a couple of times but it is not feasible to let it retry for 20 seconds)
I'm using the following settings in the config files
postgresql.conf
listen_addresses = '*'
max_connections = 500
shared_buffers = 1024MB
temp_buffers = 2MB
work_mem = 2MB
maintenance_work_mem = 128MB
pg_hba.conf
host all all 0.0.0.0/0 trust
host all all ::/0 trust
I know, I know.. It is not save to accept connections from everyone, but this is just for testing purposes and to make sure these settings are not blocking any connection. So this answer is void
I've been monitoring the number of connection on the server and under the load it is stable at 75. Postgres is using around 350mb of RAM. So given the config and the vm specs (7gb ram) there should be plenty of space to create more connections. However when the next scenario is spinning up the number of connections does not increase, it stays level and starts giving these log messages about no connection could be made.
What could be the problem here?
It does sound like this isn't really a Postgres problem (hence no changes in DB stats you're checking), rather that the traffic is being stopped by the server. Possibly because traffic on that port is saturated while handling your load testing queries?
It doesn't sound like you're hitting any of the Azure resource limits (including the database limits if that applies to your setup?), but without more detail on your load tests it's hard to say exactly what is needed.
Solutions from around the web and other SO answers suggest:
Disable TCP autotuning and tweak the TCP/IP registry keys on the server, e.g. set TcpAckFrequency - see this article for details
Make TCP setting adjustments (like WinsockListenBacklog) - which may be affected by whether connection pooling is in use or not - see this MS support article, which is for SQL Server 2005 but has some great tips on troubleshooting rejected TCP/IP connections (using Network Monitor, but applies to newer tools)
Faster request processing if you have enough control of the server - source
Disabling network proxying (in your load testing app): <defaultProxy> <proxy usesystemdefault="False"/> </defaultProxy> - source
Most possible reason is a Firewall/Anti-virus:
Software/Personal Firewall Settings
Multiple Software/Personal Firewalls
Anti-virus Software
LSP Layer
(Virtual) Router Firmware
Does your current Azure infrastructure contain Firewall or Anti-virus ?
Additionally on doing some additional searches, it looks like this is a standard Windows "connection refused" message, which suggests that PostgreSQL is trying to connect to something and being refused.
Also possible that one network element in your network - assuming that you are still connected to the server - will delay or drop somes DB login/authentication network packets (considered for example as a fake auth.replay) ...
You may also use a packet analyzer (like Wireshark) to record/inspect network flow when the error appear.
Regards
I was facing the same issue in my AspNet core application while I was trying to connect the Postgresql from my application. The error was thrown in the Program.cs file when I was calling the Migrate function.
public static void Main(string[] args) {
try {
var host = BuildWebHost(args);
using(var scope = host.Services.CreateScope()) {
// Migrate once after app is started.
scope.ServiceProvider.GetService <MyDatabaseContext>().Migrate();
}
host.Run();
}
catch(Exception e) {
//NLog: catch setup errors
_logger ? .Error(e, "Stopped program because of exception: ");
throw;
}
}
To fix this problem I did the following steps.
Check whether the Postgresql service is running by going to the services.msc
Tried to login to the pgAdmin with the user and password I provided in the database context
Everything was file, and as you know that 5432 is the default port of Postgresql and somehow I was using a different port in my application connection string, changing it to 5432 fixed this issue for me.
"ConnectionString": "User Id=postgres;Password=mypwd;Host=localhost;Port=5432;Database=mydb;"
I came across a similar issue whilst trying to beast my api, where I was seeing Npgsql.NpgsqlException No connection could be made because the target machine actively refused it..
However my issue was was down to the fact that I was re-creating my NpgsqlConnection for each query rather than re-using and keeping it alive.
I'm getting errors when trying to upload a file to FTP Server with the next VB.NET code:
Dim miUri As String = "ftp://ftp.mydomain.com/folder/file.jpg"
Dim miRequest As Net.FtpWebRequest = Net.WebRequest.Create(miUri)
miRequest.Credentials = New Net.NetworkCredential("user", "pass")
miRequest.Method = Net.WebRequestMethods.Ftp.UploadFile
Try
Dim bFile() As Byte = System.IO.File.ReadAllBytes("C:\carpeta\fichero.jpg")
Dim miStream As System.IO.Stream = miRequest.GetRequestStream()
miStream.Write(bFile, 0, bFile.Length)
miStream.Close()
miStream.Dispose()
Catch ex As Exception
Throw New Exception(ex.Message & ". El Archivo no pudo ser enviado.")
End Try
ex.Message = "Error on remote server: 227 Entering Passive Mode
(x,x,x,x,21,183). ." ex.InnerException.Message = System.Net.Sockets.SocketException = {"A socket operation was attempted to an unreachable network x.x.x.x:5557"}
The line of code that throws the exception is:
Dim miStream As System.IO.Stream = miRequest.GetRequestStream()
POINTS:
If I try to connect by FileZilla or other FTP Client, I can connect without problems.
If I disable the antivirus, I can connect without problems.
Before somebody says something related to the firewall...
IF THE ANTIVIRUS IS ON, AND I CONNECT BY FILEZILLA, I CAN CONNECT WITHOUT PROBLEMS.
¿Where is the problem? ¿What I have to do in my code to get it run with the antivirus ON?
If FileZilla can, I also have to be able...
Thanks a lot for your replies.
Regards,
Sorry for the issue.
Finally it was because of the antivirus version I had installed.
Even putting the application as a trusted application, antivirus continued blocking the application.
I installed another version of the same antivirus and everything works fine.
Regards.
"A socket operation was attempted to an unreachable network x.x.x.x:5557"
means that the server could not be reached. There are a number of reasons that could cause this issue.
The server is down.
Your computer is blocking the server connection incoming / outgoing
(firewall)
Unreliable internet access
You mis-configured your connection string (the server string)
Essentially the issue most users will experience is that their firewall is blocking access to their FTP connection request. To fix this you must allow the application through your file wall.
-Cheers
I developed an application wchich is using sockets to connect with several servers. The application works fine with WI-Fi connection but crashes on 3g connection (of course on real device, on emulator everything works fine). I cannot debug it due to the fact that it works wken phone is connected to PC. How to handle this problem?
Thanks in advance
Subscribe to both Application.UnhandledException (for UI thread exceptions) and AppDomain.Current.UnhandledException (for all unhandled exceptions) and try to write to a file before your process is terminated.
After the application crashes, use the ISETool command line to copy the data back to your machine.
Application.Current.UnhandledException += (s,e) =>
WriteExceptionFast(e.ExceptionObject, "ApplicationUnhandled");
AppDomain.Current.UnhandledException += (s,e) =>
WriteExceptionFast(e.ExceptionObject, "AppDomainUnhandled");
private void WriteExceptionFast(Exception ex, String name)
{
string filename = Path.ChangeExtension(name, ".log");
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
using (var stream = store.CreateFile(filename))
using (var writer = new StreamWriter(stream))
{
writer.WriteLine(ex.ToString());
writer.Flush();
}
}
First: catch the exceptions and read them.
Secondy: I expect that you are running into not being able to connect to sockets due to firewalls protecting intranet machines from being accessed from outside.