Recently working on a Linux platform based on the ASP. NET 5 Middleware +redis+mysql Architecture System,
Stackexchange.redis as a tool for Asp.net5 to connect to Redis. The author opened a new branch "CoreCLR" a few days ago and began to upgrade the ASP.NET5. And there is a pull request tracking related issue. Test everything on the Windows development machine to perform normally. After the migration to the Docker container on Linux, it was discovered that the ASP.NET5 middleware program would have the following error when connecting to the local Redis service via Stackexchange.redis:
System.PlatformNotSupportedException:Operation isn't supported on this platform.at System.Net.Sockets.SocketPal.Ioctl (safeclosesocket handle, Int32 IoControlCode, byte[] optioninvalue, byte[] Optionoutvalue, Int32& optionlength) at System.Net.Sockets.SocketPal.Ioctl (Safeclosesocket handle, Int32 IoControlCode, byte[] optioninvalue, byte[] optionoutvalue, Int32& optionlength) at System.Net.Sockets.Socket.IOControl (Int32 IoControlCode, byte[] optioninvalue, byte[] optionoutvalue) at StackExchange.Redis.SocketManager.SetFastLoopbackOption (socket socket)
The study found that there was a paragraph in. NET code hosted on GitHub:
Public Static int byte byte out int optionlength) { // Todo:can This is supported in some reasonable fashion? Throw New platformnotsupportedexception ();}
OK, it seems to be ready to achieve, but it is not yet realized. Well, temporarily do it yourself and change the Stackexchange.redis code. Switch
... internal Sockettoken BeginConnect (EndPoint EndPoint, Isocketcallback callback, Connectionmultiplexer multiplexer, TextWriter log) { var sock ET = new Socket (AddressFamily.InterNetwork, SocketType.Stream, PROTOCOLTYPE.TCP); try {setfastloopbackoption (socket);} catch {} socket. Nodelay = true ; try {...
This is a temporary bypass scheme that allows you to at least run the ASP.NET5 program on Linux to successfully connect to Redis. The disadvantage is that when connecting to the local Redis service, the loopback (Loopback) approach is not used, which makes the local connectivity performance improvements that should otherwise be not reflected. believe that. Net5 's sockets base class was further improved. The performance boost is still there. Technorati Tags: asp.net5,.net cross-platform, Redis,corefx,stackexchange.redis
Connect a Redis server to a Linux platform with ASP. NET 5