Connect a Redis server to a Linux platform with ASP. NET 5

Source: Internet
Author: User
Tags redis server

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.