Use ASP. NET 5 on Linux to connect to the Redis server, asp. netredis

Source: Internet
Author: User

Use ASP. NET 5 on Linux to connect to the Redis server, asp. netredis

Recently, I am working on a Linux platform based on the ASP. Net 5 middleware + Redis + Mysql architecture.

StackExchange. Redis is used as a tool for connecting asp. net5 to redis. The author opened a new branch "CoreCLR" a few days ago to start upgrading asp. net5. There is also a problem related to pull request tracking. Test everything on a Windows development machine. After being migrated to the Docker container on Linux, we found that the asp. net5 middleware program encountered the following error when connecting to the local Redis service through StackExchange. redis:

System.PlatformNotSupportedException: Operation is not 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)
After research, we found that the. Net code hosted on Github contains the following section:
public static SocketError Ioctl(SafeCloseSocket handle, int ioControlCode, byte[] optionInValue, byte[] optionOutValue, out int optionLength){    // TODO: can this be supported in some reasonable fashion?    throw new PlatformNotSupportedException();}

OK. It seems that although the implementation is prepared, it is not implemented yet. Now, you can start and modify the StackExchange. Redis code on your own. Changed:

...        internal SocketToken BeginConnect(EndPoint endpoint, ISocketCallback callback, ConnectionMultiplexer multiplexer, TextWriter log)        {            var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);            try { SetFastLoopbackOption(socket); } catch { }            socket.NoDelay = true;            try            { ...

This is a temporary bypass solution, so that the asp. net5 program that you can run on Linux at least can smoothly connect to Redis. The disadvantage is that Loopback is not used to connect to the local Redis service, which makes the performance improvement of the local connection not reflected. I believe that net5's Sockets basic class will be further improved. This performance improvement will continue. Technorati Tag: ASP. NET5,. NET cross-platform, Redis, Corefx, StackExchange. Redis

Related Article

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.