bobris / nowin Goto Github PK
View Code? Open in Web Editor NEWOwin Web Server in pure .Net
License: MIT License
Owin Web Server in pure .Net
License: MIT License
README says:
Current status is usable for testing, not for production, nobody did any security review, you have been warned.
Is there any ETA for production level? I liked Nowin a lot. I have plans to use it in production with financial services and security is a concern.
Trying to run inside a docker container, and find it can randomly die with:
System.Net.Sockets.SocketException: The socket is not connected
at System.Net.Sockets.Socket.get_RemoteEndPoint () [0x00000] in <filename unknown>:0
at Nowin.SaeaLayerCallback.ProcessAccept () [0x00000] in <filename unknown>:0
at Nowin.SaeaLayerCallback.IoCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) [0x00000] in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) [0x00000] in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.AcceptCallback (IAsyncResult ares) [0x00000] in <filename unknown>:0
at System.Net.Sockets.SocketAsyncEventArgs.DispatcherCB (IAsyncResult ares) [0x00000] in <filename unknown>:0
Is it failing to accept an incoming connection?
Any backround on what's happening here and possible workarounds would be appreciated!
This is because it does not understand PushStreamContent
Server code is here: https://github.com/friism/nowinsignalrserver/tree/master/NowinSignalRServer
This is the error I see running on Heroku on Mono (with websockets enabled):
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m /app/Microsoft.AspNet.Sign
alR.Core.dll Error : 0 : SignalR exception thrown by Task: System.AggregateExcep
tion: One or more errors occured ---> System.InvalidOperationException: Already
sending
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m at Nowin.SaeaLayerCallba
ck.StartSend (System.Byte[] buffer, Int32 offset, Int32 length) [0x00000] in <fi
lename unknown>:0
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m at Nowin.Transport2HttpH
andler.SendData (System.Byte[] buffer, Int32 offset, Int32 length) [0x00000] in
<filename unknown>:0
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m at Nowin.OwinHandler+<We
bSocketCloseAsyncMethod>d__e.MoveNext () [0x00000] in <filename unknown>:0
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m --- End of inner excepti
on stack trace ---
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m --> (Inner exception 0) S
ystem.InvalidOperationException: Already sending
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m at Nowin.SaeaLayerCallba
ck.StartSend (System.Byte[] buffer, Int32 offset, Int32 length) [0x00000] in <fi
lename unknown>:0
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m at Nowin.Transport2HttpH
andler.SendData (System.Byte[] buffer, Int32 offset, Int32 length) [0x00000] in
<filename unknown>:0
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m at Nowin.OwinHandler+<We
bSocketCloseAsyncMethod>d__e.MoveNext () [0x00000] in <filename unknown>:0
?[36m2013-08-11T16:33:25.052701+00:00 app[web.1]:?[0m
Currently default HTTPS status as reported by Chrome labels TLS 1.0 as "obsolete cryptography", could TLS 1.2 parameter be specified by default (or made configurable from the outside)?
In ParseWebSocketReceivedData
if _webSocketReceiveState == WebSocketReceiveState.Header
and there is not enough ReceiveDataLength
to read full header (ParseHeader
returns 0) the data is neither consumed nor additional receive is started. See autobahn test suite case "2.6.1" (fuzzingclient).
Before the latest changed I had a special case for ParseHeader(...) == 0
to simply call StartReciveDataIfNotAlreadyReceiving
but now it causes a StackOverflowException
because no data is consumed from Callback and StartReceiveData
calls ProcessReceive
if ReceiveDataLength > 0
. The same might happen for Close frame due to: if (Callback.ReceiveDataLength < (int)_webSocketFrameLen)
as it calls start receive without consuming data.
In my case (I am using somewhat refactored version of nowin thus a straight pull request is not possible :() I added additional buffers for header, control frame, ping frame and pong frames.
I modified ParseWebSocketReceivedData
in following ways:
ReceiveDataLength == 0
I still have to check whether I have a complete frame (in body with frame length zero or a full control frame)Header
) consume data always but start a new receive if the header is incomplete.I've found an issue with Nowin. Somehow I got into a situation where too many cookies were being added. When that happened, I got a http 500 response from nowin. After some debugging, i've narrowed the line of code where it occurs:
https://github.com/Bobris/Nowin/blob/master/Nowin/Transport2HttpHandler.cs#L346
It looks like nowin get's lost with parsing the http header and then throws an NotImplementedException.
The request header length was about 9000 bytes. So it's clearly too long, but if nowin would have returned HTTP 400 - Bad Request (Request Header too long), then it would have been immediately clear what's wrong.
If you want, I can create a repro in the form of a unit test..
Here's the http header I used:
GET http://localhost:1080 / HTTP/1.1
Host: localhost:1080
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.124 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,nl;q=0.6
Cookie: SignInMessage.9f1cc9c4ed409eb9ace9fa453d19aae0=AQAAANCMnd8BFdERjHoAwE_Cl-sBAAAAa4ZDCDenmUyKVkQePQm0tQAAAAACAAAAAAADZgAAwAAAABAAAADIXgTFFJyVWBBgictppYfnAAAAAASAAACgAAAAEAAAALeN6HgMMnouwbgBQXEV6FcIAwAA4VJaAW-qi3u6BCxvquXiod0I_QeAjpd80a1EQFvFuVuvTaVbbns6fMgaCSIIBCHl2nBBGZslErptFB9o71tRt0aTXdEnHIlAcRvzg5wqp-8BhlyGjF2rnXqsjaYeNnWfZrUC_FxQEiLwAYMD0kulYduplAGM71_eqzdwKd4eNzmJnB0rV5bBia5iwHZM3o71gz1omZuGPE7A91LMLfX8463o38bnTzfxdar724fORJ7hhbn2TFW-sNBXxVMWOYuQT7LVfCyFZQiu7m_AFWTpM9IMX60U9GWWgNO8RgRpZQShyHZU2Cso71rghIHJXQY4aifmTcn4bwzQ8rPo_vffqn-myCuUccIu5PjzudC2He37VDMZU12NwLXnmMAvM4ipfFrTaRuVEblpKO9gsq-qGiflyHF5cu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TQUFBQUFJcHBYd01Nd3dZTWcyTUgyTjNJWUtuZWdzRG5pUnpPVUpvVFg5S1hCM3dxWWotaHlVNHlzZTRpZ1RLU2YyNlFIeXpmdVdYREpLN0MwZ0VUUGtYNnVLelR2Ti1Cdjg5ZTRvQU9KcEN2bklUaUtmRjRZWTEwSlFaOGcwdGR4ZjVqU0x4OFlXUTl4dlJYNHJZTy1FT2lHel9QMzhvdDViTk1VZTRGbjBpaWdhckFVQUFBQTc4UkJNMDVxeWtqNWRCMG5QUG9iZktFU3VvOA%3D%3D
Current ParseWebSocketReceivedData
implementation ignores any data if there is no receive in progress (_webSocketReceiveTcs == null
).
Ping/Pong frames should be handled (and invisible to the application) even if there is no active receive in progress.
On badly configured machines (like mine), the call to Dns.GetHostEntry()
may throw an exception like:
System.Net.Sockets.SocketException: Could not resolve host 'foo.localnet'
This will prevent Nowin from starting up correctly regardless of what urls have been configured for binding.
When switching my app from Microsoft.Owin.Host.HttpListener to Nowin my signalr hub connections via websockets timeout and then succeed when switching to SSE.
Any idea why this is happening?
Everything else seems to work great with the switch to Nowin.
Here's the js client log showing the timeout:
[11:19:46 GMT-0500 (Eastern Standard Time)] SignalR: Negotiating with '/signalr/negotiate?clientProtocol=1.4&connectionData=%5B%7B%22name%22%3A%22eclhub%22%7D%5D'.
jquery.signalR.js:81 [11:19:46 GMT-0500 (Eastern Standard Time)] SignalR: Connecting to websocket endpoint 'ws://localhost:64423/signalr/connect?transport=webSockets&clientProtocol=1.4&connectionToken=AQAAANCMnd8BFdERjHoAwE%2FCl%2BsBAAAA3sJBIyVT%2F0m1h7OYIkqKfgAAAAACAAAAAAADZgAAwAAAABAAAAAdukww50k5%2FeCpx8dHi9pUAAAAAASAAACgAAAAEAAAAI5n9S92vwXqZCl5mr9aOaAwAAAA8%2Fo8SguGi4gUcwOYkGmUJj9T4RhUwQ1%2FGBP4fkW2QF%2FX3C44ZRjBStRxwEX2vX%2BQFAAAAGeplDn%2FBZDlgPoSMU5khj2yuSrc&connectionData=%5B%7B%22name%22%3A%22eclhub%22%7D%5D&tid=9'.
jquery.signalR.js:81 [11:19:46 GMT-0500 (Eastern Standard Time)] SignalR: Websocket opened.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: webSockets timed out when trying to connect.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Closing the Websocket.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Attempting to connect to SSE endpoint 'http://localhost:64423/signalr/connect?transport=serverSentEvents&clientPro…PoSMU5khj2yuSrc&connectionData=%5B%7B%22name%22%3A%22eclhub%22%7D%5D&tid=3'.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: EventSource connected.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: serverSentEvents transport selected. Initiating start request.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: The start request succeeded. Transitioning to the connected state.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Now monitoring keep alive with a warning timeout of 13333.333333333332 and a connection lost timeout of 20000.
jquery.signalR.js:81 [11:19:51 GMT-0500 (Eastern Standard Time)] SignalR: Invoking eclhub.getEcls
The fix introduced in 8981f8c makes some previously working queries fail for me. This is because Nowin now decodes the URL patterns like /pathBase/path?query%20ge
in a way that the %20
becomes a whitespace. If the application layer expects the non-decoded URL this is a huge problem.
As a test-case take a look at my fork's commit: pysco68@2c5d969
I'm working arround this right now by using the previous version as I didn't have any issue with the UTF8 handling (which wasn't broken to me...)
And if so, how one can access it (e.g. for printing purposes)?
Please can you advise on how to use this library to achieve Server-Sent Events
Thanks.
In the SampleOwinApp project, I'm trying to add CORS support(as suggested in SignalR docs), but when I do, nothing works. It may be the path "/signalr", but I'm not sure. This is what I have in Sample.cs
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(CorsOptions.AllowAll);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
// EnableJSONP = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
//app.MapSignalR(); // replaced by the above
Any suggestions?
I haven't had this issue on my laptop (Win 8.1), but when I run my code on my desktop machine (Win 7) I get the unhelpful exception:
An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Nowin.Server.Start()
at Nowin.OwinServerFactory.Create(Func`2 app, IDictionary`2 properties)
I've tried running as Admin, Windows Firewall is disabled, anti-virus is disabled, I've tried varying ports, disabled the VirtualBox virtual network adaptor that's on my system etc.
I changed back to using Microsoft.Owin.Host.HttpListener
as admin it just works, even on port 80.
The fact that I've had it working on my laptop makes me think its something to do with machine configuration and nothing to do with Nowin, but surely the Microsoft HttpListener is also binding to a socket?
class Program {
static void Main(string[] args) {
var options = new StartOptions {
ServerFactory = "Nowin",
Port = 8080
};
using (WebApp.Start<Startup>(options)) {
Console.WriteLine("Running a http server on port 8080");
Console.ReadKey();
}
}
}
public class Startup {
public void Configuration(IAppBuilder app) {
app.Use(async (context, task) => {
context.Response.StatusCode = 500;
if (context.Request.Path.Value == "/") {
context.Response.ContentType = "text/plain";
await context.Response.WriteAsync("Test custom 500 internal error!");
}
});
}
}
}
GET http://localhost:8080/ HTTP/1.1
User-Agent: Fiddler
Host: localhost:8080
HTTP/1.1 500 Internal Server Error
Server: Nowin
Date: Fri, 18 Sep 2015 07:34:46 GMT
Content-Length: 0
Transport2HttpHandler.cs override response when status code equals 500
// line 1287
if (_statusCode == 500 || _cancellation.IsCancellationRequested)
{
_cancellation.Cancel();
if (!_responseHeadersSend)
SendInternalServerError(); //override response
else
{
_isKeepAlive = false;
if (_statusCode == 500)
{
SendHttpResponseAndPrepareForNext();
return;
}
CloseConnection();
}
return;
}
Start nowin sample browse to
http://localhost:8888/Åsna
The decoded URL will be wrong. /�sna see the tilde instead of the ring?
We've spotted a possible socket leak on linux v3.18.6 and mono 3.12.0
The source for a demo app is at : https://github.com/VQComms/SelfHostWithOwin
To reproduce run:
mono SelfHostWithOwin.exe
ps
Make note of process id
Use curl/wget to hit http://localhost:1999
Run ls /proc/{PID}/fd -l
Make note of number of socket handles present
Use curl/wget to hit http://localhost:1999 again
Run ls /proc/{PID}/fd -l
Make note of number of socket handles present and notice it has increased
It appears to increase each socket handler per request
Using Nowin.vNext and Nowin 0.11 on mono, if I run k web
and exit, then run it again, I get this error.
If I wait a minute it starts working again. I don't know why it fails intermittently (DNS caching by OS X perhaps?), but I suppose throwing a Distinct()
before the ToDictionary()
would be a prudent fix.
System.ArgumentException: An element with the same key already exists in the dictionary.
at System.Collections.Generic.Dictionary`2[System.Net.IPAddress,System.Boolean].Add (System.Net.IPAddress key, Boolean value)
at System.Linq.Enumerable.ToDictionary[IPAddress,IPAddress,Boolean] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector, IEqualityComparer`1 comparer)
at System.Linq.Enumerable.ToDictionary[IPAddress,IPAddress,Boolean] (IEnumerable`1 source, System.Func`2 keySelector, System.Func`2 elementSelector)
at Nowin.IpIsLocalChecker..ctor ()
at Nowin.Server.Start ()
at Nowin.vNext.NowinServerFactory.Start (IServerInformation serverInformation, System.Func`2 application)
at Microsoft.AspNet.Hosting.HostingEngine.Start
I have a rather annoying problem with WebSockets, in that the initial connection has a 50/50 chance of opening properly in the browser. Every time though, the server handler opens a websocket and reports its listening.
This basic middleware reproduces the problem.
namespace Owin
{
using AppFunc = Func<IDictionary<string, object>, Task>;
using WebSocketAccept = Action<IDictionary<string, object>, Func<IDictionary<string, object>, Task>>;
using WebSocketCloseAsync = Func<int, string, CancellationToken, Task>;
using WebSocketReceiveAsync = Func<ArraySegment<byte>, CancellationToken, Task<Tuple<int, bool, int>>>;
using WebSocketSendAsync = Func<ArraySegment<byte>, int, bool, CancellationToken, Task>;
public static class OwinWebSocketExtension
{
public static void UseOwinWebSocket(this IAppBuilder app)
{
app.Use(new Func<AppFunc, AppFunc>(next => (async env =>
{
var context = env;
WebSocketAccept accept =
context.ContainsKey("websocket.Accept")
? (WebSocketAccept) context["websocket.Accept"]
: null;
if (accept == null)
{
await next.Invoke(env);
return;
}
accept(null, async (owinContext) =>
{
Console.WriteLine("WebSocket Entry");
var sendAsync = (WebSocketSendAsync)owinContext["websocket.SendAsync"];
var receiveAsync = (WebSocketReceiveAsync)owinContext["websocket.ReceiveAsync"];
var closeAsync = (WebSocketCloseAsync)owinContext["websocket.CloseAsync"];
var cancel = (CancellationToken)owinContext["websocket.CallCancelled"];
byte[] buffer = new byte[4096];
bool closed = false;
try
{
while (closed == false && cancel.IsCancellationRequested == false)
{
using (var memoryStream = new MemoryStream())
{
int messageType = 0;
while (cancel.IsCancellationRequested == false)
{
var segment = new ArraySegment<byte>(buffer);
var result = await receiveAsync(segment, cancel);
messageType = result.Item1;
var endOfMessage = result.Item2;
var messageSize = result.Item3;
memoryStream.Write(segment.Array, segment.Offset, messageSize);
if (endOfMessage)
break;
}
if (cancel.IsCancellationRequested)
break;
memoryStream.Position = 0;
switch (messageType)
{
case 0x1: // Text
break;
case 0x2: // Binary
break;
case 0x8: // Close
await closeAsync(1000, string.Empty, cancel);
closed = true;
break;
case 0x9: // Ping
await
sendAsync(new ArraySegment<byte>(memoryStream.ToArray()), 0xA, true, cancel);
break;
case 0xA: // Pong
break;
}
}
}
}
catch (Exception e)
{
Console.WriteLine($"WebSocket Error {e}");
}
Console.WriteLine("WebSocket Exit");
});
})));
}
}
}
if you run this in either chrome or firefox and refresh a few times.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<script>
var url = "ws://127.0.0.1:8080/";
var ws = new WebSocket(url);
ws.onopen = function() {
console.log("OnOpen");
};
ws.onclose = function() {
console.log("OnClose");
};
ws.onerror = function(e) {
console.log("OnError");
};
$(window).on('beforeunload', function() {
ws.close();
});
</script>
</body>
</html>
Most of the time it will work and you'll see "OnOpen" in the console. Other times the console output will be empty, however the Tasks for the Owin Websocket are still active and not canceled. The way it acts (random whether it opens or not) gives me the impression there is a Race condition happening somewhere. And given the behavour occurs in both chome and firefox I suspect its somewhere in Nowin.
If eg. you pass a dodgy certificate to Nowin the call to _ssl.AuthenticateAsServerAsync
returns with t.IsFaulted == true.
This causes the following line to run :
self._next.FinishAccept(null, 0, 0, null, null);
FinishAccept then throws an ObjectReference error because localEndPoint is now null.
According to sample code, it seems that SSL support requires Nowin server to be instantiated directly, lacking the support for Microsoft.Owin.Hosting.
I've written an application which is form-based, it does some interval updates, I wanted to know if it's possible to provide an example of what it would look like to configure this application to use a BackgroundWorker such that the webserver could run in background while in a WinForm application.
Hi Boris, I've added a repo here - https://github.com/samcov/NoWinCorsLocal
In Sample.cs, there is a DoCors variable initially set to false. When false, if you run it, it works fine in IE11, but only because IE doesn't flag CORS locally, it fails in Chrome & FF!
However, if CORS support is added, nothing works.
The website launches singalr.aspx, which is essentially your signalr.html converted to aspx.
If you have any additional questions, you can email me at [email protected], or respond here.
Thanks,
Sam...
owin.CallCancelled should be cancelled and server code registered callback should be called.
owin.CallCancelled not cancelled on client TCP connection closed or dropped
Hello,
I'm currently trying to migrate an existing OWIN application to be hosted with Nowin. It worked mostly flawlessly (and with good performance results). However on of the last missing pieces is that Nowin seemingly doesn't provide a CancellationToken
under the key host.OnAppDisposing
in the application dictionary.
This cancellation token can be used to hook into the disposal process of the application, which can be very useful to dispose things like singletons that were instantiated during the web-application's setup, whitout having to build-up too much messy code.
If you could pinpoint where I should look at to implement the missing parts I'd be happy to contribute to this great project!
Here's some information about the topic:
In a nowin app, with or without nancyfx (we use nancy for development, with and without razor)
using the certificate for https, the app hangs at first or max second successfull connection, because cannot close connections to the certificate handshake, tcp ports on server side remain in "close wait" state, any new connection add another connection in this state without showing anyting,
in our case this reproducible always in a linux 64 bit machine with mono 3.x > 4.3.x (git)
with sources compiled in mono (framework 4.0) or in windows (4.2, 4.2.x) and running the compiled software in mono or official .net framwerk of both platforms, in debug mode in visual studio, the problem it's less frequently.
Looking other Bugs, seems quite similar to the "F5" bug (#52).
#52
sees a memory problem, or a certificate stream problem on the passthrough after the certicate loading and become a deadlock on tcp port communication after initial connection.
service LIsten correctly but handshake remain locked on the server side.
How can I force the client to authenticate with a certificate with Nowin host?
EDIT: I can check "ssl.ClientCertificate", but how do I tell the browser to prompt the user for a certificate? My understanding is it needs to happen during TLS negotiation, not sure I could influence it after the fact (via headers, status codes).
There seems to exist a bad interaction between libcurl and Nowin with SSL/TLS persistent connections.
curl -v -3 https://somenowinserver.com/robots.txt https://somenowinserver.com/robots.txt https://somenowinserver.com/robots.txt 2>&1 | grep -i connection
* SSL connection using SSLv3 / DES-CBC3-SHA
* Connection #0 to host somenowinserver.com left intact
* Re-using existing connection! (#0) with host somenowinserver.com
* Connection #0 to host somenowinserver.com left intact
* Connection 0 seems to be dead!
* Closing connection 0
* SSL connection using SSLv3 / DES-CBC3-SHA
* Connection #1 to host somenowinserver.com left intact
The 2nd GET resumes SSL session (Re-using existing connection
) but the 3rd doesn't (Connection 0 seems to be dead!
)
I was able to reproduce the problem both with Windows client and Linux (Ubuntu) client. I noticed this problem with Nowin version 0.16.0.0 but 0.22.2.0 also behaves in the same way.
IOwinRequest.Body
stream in Nowin, backed by the ReqRespStream
class, does not implement the Length
property correctly with regard to the value of the CanSeek
property. MSDN docs have this note in Stream.CanSeek
:
If a class derived from Stream does not support seeking, calls to Length, SetLength, Position, and Seek throw a NotSupportedException.
Nowin returns value of Content-Length
header instead. Kestrel on the other hand throws NotSupportedException correctly (PR aspnet/KestrelHttpServer#256).
The violation of contract for IOwinRequest.Body.Length
makes it difficult to host same OWIN middleware on both Nowin and Kestrel - their behavior is not same.
When using Nowin with ASP.NET 5 and pressing F5 repeatedly I get a hang within Nowin. Is Nowin handling sockets properly?
I got this exception and it caused my app to fail.
Exception Info: System.InvalidOperationException
Stack:
at Nowin.SaeaLayerCallback.StartReceive(Byte[], Int32, Int32)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net.Sockets.SocketFlags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped_)
at System.Threading.IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped)
can you port nowin for aspnetcore50?
i tried...
on aspnet50 it works, but there are thousands of error on aspnetcore50...
Is it possible?
If I use nowin to host an application, that also uses webapi, then routeparameters and querystring parameters are not automatically decoded.
This appears to be different behavior than we get from the microsoft owin selfhost or from our unit tests (which test the owin pipeline without a webserver).
What's the behavior? if we issue a http request with url encoded parameters (IE: /api/path?param=thisIsAnEncoded%23Hastag, then in webapi, this parameter is still encoded (it still has the %23 in it).
But in our unit tests, OR if I run in the owin selfhost, I get the decoded value (with a # in it).
Is this behavior by design?
Your server was recommended to me by David Fowler, and I'm glad he did.
I tried out the sample and it works like a charm, however, I noticed that you're using SignalR 2.x.
My question is if this will work with SignalR 1.x, although it doesn't appear that it should be a problem, I still thought I would ask.
Thanks!
This is more of a question than an issue, so here goes.
Your webserver only handles HTML, not aspx pages, but I want to use Asp.Net, so here's the question.
Would it be possible to use IIS with an ASPX page, and point SignalR to a hub hosted in Nowin?
SignalR has a setting to set the hub URL
$.connection.hub.url = 'http://76.90.50.83/signalr'; // use the Hub on another server... Fantastic!!!
So I wonder if you know if this will work? Or possibly you can see that it won't work, but if it does, your product just shot up the ladder as a god send for all of us that can't get customers off of Windows Server 2008R2.
If you don't, I guess we'll have to test it, but intuitively, it appears to make sense!
Hi - Not really sure what this means - any help would be appreciated.
Thanks
Andy
Exception:
System.InvalidOperationException: Already receiving or accepting
at Nowin.SaeaLayerCallback.StartReceive(Byte[] buffer, Int32 offset, Int32 length)
at Nowin.Transport2HttpHandler.StartNextReceive()
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
Hi
I just receieved this error while selfhosting SignalR 2.1.
Server running on http://localhost:8081
SignalRSelfHost.vshost.exe Warning: 0 : SignalR exception thrown by Task: System
.AggregateException: One or more errors occurred. ---> System.NotImplementedExce
ption: The method or operation is not implemented.
at Microsoft.AspNet.SignalR.Owin.OwinWebSocketHandler.OwinWebSocket.get_State
()
at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.SendAsync(ArraySegmen
t1 message, WebSocketMessageType messageType, Boolean endOfMessage) at Microsoft.AspNet.SignalR.WebSockets.DefaultWebSocketHandler.Flush() at Microsoft.AspNet.SignalR.Transports.WebSocketTransport.<PerformSend>d__8.M oveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot ification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Microsoft.AspNet.SignalR.Transports.WebSocketTransport.<PerformSend>d__8.M oveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot ification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Microsoft.AspNet.SignalR.Messaging.Subscription.d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNet.SignalR.Messaging.Subscription.<Work>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot ification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at Microsoft.AspNet.SignalR.Messaging.MessageBroker.<DoWork>d__2.MoveNext() --- End of inner exception stack trace --- ---> (Inner Exception #0) System.NotImplementedException: The method or operatio n is not implemented. at Microsoft.AspNet.SignalR.Owin.OwinWebSocketHandler.OwinWebSocket.get_State () at Microsoft.AspNet.SignalR.WebSockets.WebSocketHandler.SendAsync(ArraySegmen t
1 message, WebSocketMessageType messageType, Boolean endOfMessage)
at Microsoft.AspNet.SignalR.WebSockets.DefaultWebSocketHandler.Flush()
at Microsoft.AspNet.SignalR.Transports.WebSocketTransport.d__8.M
oveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNet.SignalR.Transports.WebSocketTransport.d__8.M
oveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNet.SignalR.Messaging.Subscription.<Invoke>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot ification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Microsoft.AspNet.SignalR.Messaging.Subscription.d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNot
ification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNet.SignalR.Messaging.MessageBroker.d__2.MoveNext()<---
I was hoping that I could use this to run websockets on pre win 8 / win2012 machine
I can send a sample app if required.
Regards
In a large test-suite where we rely on ExecutionContext
to be able to flow we have noticed that running Nowin
breaks our tests. We have identified the source of the problem in SaeaLayerCallback.cs.
Please consider wrapping the suppression in a using statement at the correct level so that the async methods don't flow context but the main thread can retain the context flowing for the rest of the application.
你好,是否有新版本更新呢?
Do you have a sample like in the README to show how to use Nowin using ASP.Net vNext?
Hi
tl/dr: reproducible example of instabilities: data corruption, assertions, null ref exceptions probably caused by bug within transport layer is attached.
I know you are deprecating this in favour of kestrel, but we were evaluating the library for use with an existing mono based server which needs to target quite a few obscure architectures (e.g. mono on qnap on various flavours of arm). I'm not sure that the kestrel stuff will work for us right now for that reason. A simple test of kestrel on mac using mono died horribly. I also didn't get as far as finding/porting the libuv stuff for qnap, so this project seemed like a good stopgap.
Anyway, long story short, some of our clients were experiencing receiving random connection closes from the server (we were never actively closing from the server!). So I wrote a stress test app (attached) and it seems to display quite a lot of instability.
I swapped out a couple of alternative server implementations (MSHttpListener and kestrel). They run stably, so I'm guessing that nowin is the culprit. The owin.websocket wrapper is fairly trivial and the errors all seem to be down at the transport layers.
Errors seen include null ref on _socket in SaeaLayerCallback - : _socket.ReceiveAsync(_receiveEvent); line 270.
I also saw an assertion followed by some corrupted websocket message data being passed up to the higher layers. Think the assertion was
Debug.Assert(StartBufferOffset + ReceiveBufferPos == offset || _waitingForRequest); in Transport2HttpHandler, line 1039.
Anyway, it's all a bit intermittent and probably all caused by a single low level bug down in the guts of the transport layers. I'll try and have a pop at it, but no guarantees I'll be able to find it :)
If you have any pointers towards helping me debug this / potentially weak areas etc I'd be really grateful for any input!
Cheers
Iain
While testing establishment of 100k connections and then dropping 50k, I saw that not all of the connection were disconnected. Culprit: in SslTransportHandler.StartReceive consider wrapping call to _ssl.ReadAsync in try-catch, and handling error properly (i.e. FinishReceive(null, 0, -1)). Also, I guess same makes sense for StartSend
As have written in my last bug report, I have a load balancing app which disposed the server every 10 seconds, wait 10 seconds, starts it again and tests if our lib behaves correctly in a loop. While doing this I felt a few times over this exception which crashes the process.
Unhandled Exception: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.SocketAsyncEventArgs'.
at System.Net.Sockets.SocketAsyncEventArgs.StartConfiguring()
at System.Net.Sockets.SocketAsyncEventArgs.SetBufferInternal(Byte[] buffer, Int32 offset, Int32 count)
at Nowin.SaeaLayerCallback.StartReceive(Byte[] buffer, Int32 offset, Int32 length)
at Nowin.Transport2HttpHandler.RealStartNextReceive()
at Nowin.Transport2HttpHandler.FinishReceive(Byte[] buffer, Int32 offset, Int32 length)
at Nowin.SaeaLayerCallback.ProcessReceive()
at Nowin.SaeaLayerCallback.IoCompleted(Object sender, SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
From what I could see with my limited knowledge of the codebase is that the _receiveEvent.SetBuffer(buffer, offset, length);
lines should be moved into the try-catch block three lines below.
If you implement the following pattern:
It'll make it possible to boot nowin using owinhost.exe and WebApp.Start. I have another example of the pattern here:
https://github.com/davidfowl/Webstack/blob/master/WebStack/OwinServerFactory.cs
Usage:
https://github.com/davidfowl/Webstack/blob/master/WebStack.Sample/Program.cs
0.16.0 disabled SSL v3 by default: f869c95#diff-608c40426c1568b8a09cd18fa10edfcaR15
IMHO, since this break things, I'd say this deserves at least a clear announcement.
FWIW, .Net framework's default still includes SSL v3: http://referencesource.microsoft.com/#System/net/System/Net/SecureProtocols/SslEnumTypes.cs,23
A Klondike user discovered that requests that try to upload more 5-10 mb of data in a request body handled by Nowin will cause the request to timeout on the client and the request processing thread appears to deadlock.
This deadlock does not occur in Klondike when using the Microsoft.Owin.Host.HttpListener
server factory, so I think the bug is in Nowin and not Klondike.
Klondike sometimes reads only a few bytes at a time in order to work around some bugs in the NuGet command line client, so it's possible this bug has to do with reading only a few bytes sometimes instead of asking for 1024 bytes at a time.
Cross-reference https://github.com/themotleyfool/Klondike/issues/121
Stack trace of request thread:
mscorlib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout, bool exitContext) Unknown
mscorlib.dll!System.Threading.Monitor.Wait(object obj, int millisecondsTimeout) Unknown
mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown
mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown
mscorlib.dll!System.Threading.Tasks.Task.InternalWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown
mscorlib.dll!System.Threading.Tasks.Task<int>.GetResultCore(bool waitCompletionNotification) Unknown
mscorlib.dll!System.Threading.Tasks.Task<int>.Result.get() Unknown
Nowin.dll!Nowin.ReqRespStream.Read(byte[] buffer, int offset, int count) Line 49 C#
System.Web.Http.Owin.dll!System.Web.Http.NonOwnedStream.Read(byte[] buffer, int offset, int count) Unknown
System.Net.Http.dll!System.Net.Http.DelegatingStream.Read(byte[] buffer, int offset, int count) Unknown
> NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Formatters.MalformedMultipartFixingStream.ReplaceMalformedBoundary(byte[] buffer, int offset, int count, int matchIndex, int matchLength, int totalBytesRead) Line 124 C#
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Formatters.MalformedMultipartFixingStream.ProcessBytesRead(byte[] buffer, int offset, int count, int totalBytesRead, int bytesRead) Line 101 C#
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Formatters.MalformedMultipartFixingStream.BufferedReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) Line 76 C#
[Resuming Async Method]
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.MoveNextRunner.Run() Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.OutputAsyncCausalityEvents.AnonymousMethod__1() Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown
mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.OutputWaitEtwEvents.AnonymousMethod__1() Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ContinuationWrapper.Invoke() Unknown
mscorlib.dll!System.Threading.Tasks.AwaitTaskContinuation.RunOrScheduleAction(System.Action action, bool allowInlining, ref System.Threading.Tasks.Task currentTask) Unknown
mscorlib.dll!System.Threading.Tasks.Task.FinishContinuations() Unknown
mscorlib.dll!System.Threading.Tasks.Task.FinishStageThree() Unknown
mscorlib.dll!System.Threading.Tasks.Task<int>.TrySetResult(int result) Unknown
mscorlib.dll!System.Threading.Tasks.TaskCompletionSource<int>.TrySetResult(int result) Unknown
Nowin.dll!Nowin.ReqRespStream.ProcessDataAndShouldReadMore() Line 156 C#
Nowin.dll!Nowin.Transport2HttpHandler.ProcessReceive() Line 1124 C#
Nowin.dll!Nowin.Transport2HttpHandler.FinishReceive(byte[] buffer, int offset, int length) Line 1031 C#
Nowin.dll!Nowin.SaeaLayerCallback.ProcessReceive() Line 168 C#
Nowin.dll!Nowin.SaeaLayerCallback.IoCompleted(object sender, System.Net.Sockets.SocketAsyncEventArgs e) Line 102 C#
System.dll!System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs e) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError socketError, int bytesTransferred, System.Net.Sockets.SocketFlags flags) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) Unknown
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
[Async Call]
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Formatters.MalformedMultipartFixingStream.ReadAsync(byte[] buffer, int offset, int count, System.Threading.CancellationToken cancellationToken) Line 42 C#
[Async Call]
System.Net.Http.Formatting.dll!System.Net.Http.HttpContentMultipartExtensions.MultipartReadAsync(System.Net.Http.HttpContentMultipartExtensions.MultipartAsyncContext context, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Net.Http.Formatting.dll!System.Net.Http.HttpContentMultipartExtensions.ReadAsMultipartAsync<NuGet.Lucene.Web.Formatters.HashingMultipartFileStreamProvider>(System.Net.Http.HttpContent content, NuGet.Lucene.Web.Formatters.HashingMultipartFileStreamProvider streamProvider, int bufferSize, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Formatters.MultipartFormDataMediaFormatter<NuGet.IPackage, NuGet.Lucene.Web.Formatters.HashingMultipartFileStreamProvider>.ReadFromStreamAsync(System.Type type, System.IO.Stream readStream, System.Net.Http.HttpContent content, System.Net.Http.Formatting.IFormatterLogger formatterLogger) Line 38 C#
[Async Call]
System.Net.Http.Formatting.dll!System.Net.Http.HttpContentExtensions.ReadAsAsyncCore<object>(System.Net.Http.HttpContent content, System.Type type, System.Net.Http.Formatting.IFormatterLogger formatterLogger, System.Net.Http.Formatting.MediaTypeFormatter formatter, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Web.Http.dll!System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsyncCore(System.Web.Http.Metadata.ModelMetadataProvider metadataProvider, System.Web.Http.Controllers.HttpActionContext actionContext, System.Web.Http.Controllers.HttpParameterDescriptor paramFromBody, System.Type type, System.Net.Http.HttpRequestMessage request, System.Net.Http.Formatting.IFormatterLogger formatterLogger, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Web.Http.dll!System.Web.Http.Controllers.HttpActionBinding.ExecuteBindingAsyncCore(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Web.Http.dll!System.Web.Http.Controllers.ActionFilterResult.ExecuteAsync(System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Web.Http.dll!System.Web.Http.Filters.AuthorizationFilterAttribute.ExecuteAuthorizationFilterAsyncCore(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken, System.Func<System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>> continuation) Unknown
[Async Call]
System.Web.Http.dll!System.Web.Http.Controllers.ExceptionFilterResult.ExecuteAsync(System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.MessageHandlers.CrossOriginMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Line 41 C#
[Async Call]
System.Web.Http.dll!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
[Async Call]
System.Web.Http.Owin.dll!System.Web.Http.Owin.HttpMessageHandlerAdapter.InvokeCore(Microsoft.Owin.IOwinContext context, Microsoft.Owin.IOwinRequest owinRequest, Microsoft.Owin.IOwinResponse owinResponse) Unknown
[Async Call]
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Middleware.AuthenticationMiddlewareBase.Invoke(Microsoft.Owin.IOwinContext context) Line 21 C#
[Async Call]
NuGet.Lucene.Web.dll!NuGet.Lucene.Web.Middleware.AuthenticationMiddlewareBase.Invoke(Microsoft.Owin.IOwinContext context) Line 21 C#
[Async Call]
Autofac.Integration.Owin.dll!Owin.OwinExtensions.UseAutofacMiddleware.AnonymousMethod__0(Microsoft.Owin.IOwinContext context, System.Func<System.Threading.Tasks.Task> next) Unknown
[Async Call]
Microsoft.Owin.Diagnostics.dll!Microsoft.Owin.Diagnostics.ErrorPageMiddleware.Invoke(System.Collections.Generic.IDictionary<string, object> environment) Unknown
[Async Call]
Klondike.WebHost.dll!Klondike.AppBuilderExtensions.UseFallbackFile.AnonymousMethod__0(Microsoft.Owin.IOwinContext ctx, System.Func<System.Threading.Tasks.Task> next) Line 20 C#
Stack trace of another thread:
> Nowin.dll!Nowin.Transport2HttpHandler.FinishReceive(byte[] buffer, int offset, int length) Line 1029 C#
Nowin.dll!Nowin.SaeaLayerCallback.ProcessReceive() Line 168 C#
Nowin.dll!Nowin.SaeaLayerCallback.IoCompleted(object sender, System.Net.Sockets.SocketAsyncEventArgs e) Line 102 C#
System.dll!System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs e) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError socketError, int bytesTransferred, System.Net.Sockets.SocketFlags flags) Unknown
System.dll!System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) Unknown
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
Is there a way to specify timeout for keep-alive connections?
Say HTTP clients need long standing (10+min) connections. How to make that happen?
Correct me if I am wrong, but the given code fragment should not end in an memory leak. But it leaks 15mb on every loop and does not seems to free it, not event with an GC.Collect();
while(true){
var serverBuilder = new ServerBuilder();
serverBuilder.SetPort(8081);
var server = serverBuilder.Start();
Thread.Sleep(500);
server.Dispose();
}
To give a little bit feedback why I felt onto this. I have an test app for an internal lib which creates and disposes the server every 10 seconds and test if the lib behaves correctly. But since the server leaks memory, it runs not very long.
I dug a little bit into the codebase of Nowin, but I dont saw anything yet which could cause this leak.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.