I have started seeing these errors in the javascript console recently, although using SignalR for a long time. So maybe due to a version update in the client microsoft/signalR
Utils.js:218 [2021-07-28T15:36:22.247Z] Error: Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'.
So I added these lines to the client code (commented newly added), this reduced the frequency of the errors, but those did not go away:
connectSignalRHub() {
const liveMarginHub = new SignalR.HubConnectionBuilder()
.withUrl(buildSignalRUrl('liveUpdateHub'))
.withAutomaticReconnect() // newly added
.configureLogging(SignalR.LogLevel.Error)
.build();
// newly added
liveMarginHub.keepAliveIntervalInMilliseconds = 1000 * 60 * 3; // Three minutes
liveMarginHub.serverTimeoutInMilliseconds = 1000 * 60 * 6; // Six minutes
The backend is ASP.NET core. I see there are options of specifying timeouts there as well, like
sc.AddSignalR(c =>
{
c.EnableDetailedErrors = true;
c.ClientTimeoutInterval = TimeSpan.MaxValue;
c.KeepAliveInterval = TimeSpan.MaxValue;
});
But is this a right thing to do? I am just trying to make the timeout error message go away from the UI console.
Thanks
Related
I have an asp.net core 3.0 website. It has a controller that implements an HttpGet function that does some database stuff then returns a Json object (https://localhost:44356/api/runner/match).
I have a console application that uses an HttpClient to hit that url. I launch the site locally and then I launch my console app. About 50% of the time it works. The other 50% of the time I get:
HttpRequestException: No connection could be made because the target machine actively refused it.
SocketException: No connection could be made because the target machine actively refused it.
I'm trying to figure out why my console app's connection is being blocked. I don't know how to start debugging this. I tried to implement a retry on the request, but once I get the exception, I keep getting it. So I think it's something non-deterministic happening in my website, potentially related to SSL?
I'm able to hit the url in Chrome locally just fine.
How do I figure out what is blocking the connection from being made?
Is there any chance this is something IIS Express is doing?
Calling code in console app:
static async Task<List<Deck>> GetMatchData()
{
string baseUrl = "https://localhost:44356/api/runner/match";
using (HttpClient client = new HttpClient())
{
HttpResponseMessage res = null;
res = await client.GetAsync(baseUrl);
Controller function:
[HttpGet("match")]
public async Task<ActionResult> GetMatchup()
{
int count = db.Decks.Count();
Random r = new Random();
int d1 = r.Next(count) + 1; // database ids start at 1 for some reason
int d2 = r.Next(count - 1) + 1;
if (d1 == d2)
d2++;
List<Deck> result = new List<Deck>();
result.Add(await db.Decks.FindAsync(d1));
result.Add(await db.Decks.FindAsync(d2));
if (result[0] == null || result[1] == null)
{
return BadRequest();
}
return Ok(result);
}
try
HttpClient httpClient = new HttpClient();
//specify to use TLS 1.2 as default connection
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
string baseUrl = "https://localhost:44356/api/runner/match";
httpClient.BaseAddress = new Uri(baseUrl );
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var getResult = await httpClient.GetAsync(baseUrl);
Now I have ktor server is based on netty.
When I do to long GET request (about 9300 characters (mostly in query params)), ktor answers Unhandled: GET - /bad-request.
If I reduce length of url, it works fine.
In your embedded server config you can provide a function “httpServerCodec” to create HttpServerCodec (https://netty.io/4.1/api/io/netty/handler/codec/http/HttpServerCodec.html) in which you can set the maxInitialLineLength property.
embeddedServer(Netty, configure = {
// Size of the queue to store [ApplicationCall] instances that cannot be immediately processed
requestQueueLimit = 16
// Do not create separate call event group and reuse worker group for processing calls
shareWorkGroup = false
// User-provided function to configure Netty's [ServerBootstrap]
configureBootstrap = {
// ...
}
httpServerCodec = {
HttpServerCodec(.......)
}
// Timeout in seconds for sending responses to client
responseWriteTimeoutSeconds = 10
}) {
// ...
}.start(true)
Using:
StackExchange.Redis v1.1.608.0
RedLock.net v1.7.4.0
This code always returns false after 250-600ms:
var eps = new [] { new DnsEndPoint("localhost", 6379) };
var lf = new RedisLockFactory(eps);
var resource = "the-thing-we-are-locking-on";
var expiry = TimeSpan.FromSeconds(30);
using (var redisLock = lf.Create(resource, expiry))
{
Response.Write("Lock acquired: " + redisLock.IsAcquired);
}
I'm struggling to work out why, as I'm able to cache things in Redis just fine with StackExchange.Redis connection string localhost,allowAdmin=true.
In the Redis console I can see a client is being connected, but that's as far as it gets.
I've added a firewall rule for port 6379 but nothing changed.
Any ideas on my the lock can never be acquired?
Found the cause of the issue. I'm using MSOpenTech Redis server v3.2.100:
https://github.com/MSOpenTech/redis/releases
Rolling back to v3.0.500 appears to fix the issue. Not ideal, but in testing environment should be OK for now.
I am receiving a timeout from the Sharepoint Client Managed Object model.
Microsoft.SharePoint.Client.ServerException: The operation has timed out.
Basically, I am batching 100 updates and sending them at one go. It is no problem for me if takes time but I really want to avoid timeout exception.
I have tried in a million of ways to increase the timeout in the client context but they were all without success. I have used reflection to try to identity what the sharepoint is doing when calling the executequery method of the client context. sharepoint is basically creating an HttpWebRequest and sending it.
I have ended with the below code, but still without success:
public static void SetInfinteTimeout(this ClientContext ctx)
{
int timeout = 10 * 60 * 1000;
ctx.RequestTimeout = timeout;
ctx.PendingRequest.RequestExecutor.RequestKeepAlive = false;
ctx.PendingRequest.RequestExecutor.WebRequest.KeepAlive = false;
ctx.PendingRequest.RequestExecutor.WebRequest.Timeout = timeout;
ctx.PendingRequest.RequestExecutor.WebRequest.ReadWriteTimeout = timeout;
System.Net.ServicePointManager.DefaultConnectionLimit = 200;
System.Net.ServicePointManager.MaxServicePointIdleTime = 2000;
System.Net.ServicePointManager.MaxServicePoints = 1000;
System.Net.ServicePointManager.SetTcpKeepAlive(false, 0, 0);
ServicePointManager.DnsRefreshTimeout = timeout; // 10 minutes
}
But I am still receiving a timeout error!
Is there anything else that I am missing please?
Any assistance would be greatly appreciated.
Have you tried
keeping default KeepAlive (true),
disabling Timeout and
keeping default MaxServicePointIdleTime value (which is 100 seconds by
default but you set to 2).
Just as:
public static void SetInfiniteTimeout(this ClientContext ctx)
{
ctx.RequestTimeout = -1; //ctx.RequestTimeout or System.Threading.Timeout.Infinite;
}
Also, how many seconds it takes for you to get timeout error, in your current configuration?
The solution was to use clientcallablesettings (SPWebApplication.ClientCallableSettings):
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.clientcallablesettings.aspx
This has an execution timeout property and other related settings.
In my case, I needed to add this in the Upgrade Actions as per the below code
using (SPSite site = new SPSite(siteURL))
using (SPWeb web = site.OpenWeb())
{
site.WebApplication.ClientCallableSettings.ExecutionTimeout = TimeSpan.FromMinutes(60);
site.WebApplication.ClientCallableSettings.MaxObjectPaths = 1000;
site.WebApplication.ClientCallableSettings.MaxResourcesPerRequest = 1000;
site.WebApplication.ClientCallableSettings.EnableStackTrace = true;
site.WebApplication.Update();
}
I am using WCF for sending and getting data to and from 2 different win form applications running in the same machine. I am using namedpipe and duplexchannel. My client side implementation is shown below.
InstanceContext myContext = new InstanceContext(this);
NetNamedPipeBinding nb = new NetNamedPipeBinding();
nb.MaxBufferPoolSize = 5000000;
nb.MaxBufferSize = 500000;
nb.MaxReceivedMessageSize = 500000;
nb.ReceiveTimeout = TimeSpan.FromMinutes(5);
DuplexChannelFactory<IService> myProxy = new DuplexChannelFactory<IService>(myContext, nb, new EndPointAddress("net.pipe://localhost/MyService"));
IService myServiceClient = myProxy.CreateChannel();
And Server side implementation is shown below:
NetNamedPipeBinding np = new NetNamedPipeBinding();
np.MaxBufferPoolSize = 5000000;
np.MaxBufferSize = 500000;
np.MaxReceivedMessageSize = 500000;
host.AddServiceEndpoint(typeof(IService), np, "net.pipe://localhost/MyService");
host.OpenTimeout = TimeSpan.FromMinutes(5);
host.CloseTimeout = TimeSpan.FromMinutes(5);
host.Open();
I can pass about 100 object collection (ObservableCollection<Customer>) from 1 application through callback to other app. But if I make it 1000 or greater objects, the following Timeout Exception error occurs.
The write to the pipe did not complete
within the allotted timeout of
00:00:00. The time allotted to this
operation may have been a portion of a
longer timeout.
What is the fault in my code ? Please help me to overcome this issue.
Thanks in advance...
Looks like this question was also asked and answered here:
http://social.msdn.microsoft.com/Forums/eu/wcf/thread/38926593-8ea6-481d-8c43-072b73292f6a