aerospike / aerospike-client-csharp

Aerospike C# Client Library
70 stars 48 forks source link

Error using AsyncClient on .Net Core #30

Closed Caldas closed 3 years ago

Caldas commented 7 years ago

When using real async call with CancellationToken async client is throwing error for Put and Get methods (that I tested)

Here is a sample call:

await client.Put(null, CancellationToken.None, GetKey("4"), new Bin("test", "2"));

I went at your test code AsyncPutGetWithTask but I don't know why here only sync calls are working

Caldas commented 7 years ago

Error at innerException: at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)\n at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue, Boolean silent)\n at System.Net.Sockets.Socket.SetSocketOption(SocketOptionLevel optionLevel, SocketOptionName optionName, Int32 optionValue)\n at System.Net.Sockets.Socket.set_SendBufferSize(Int32 value)\n at Aerospike.Client.AsyncConnection..ctor(IPEndPoint address, AsyncCluster cluster)

BrianNichols commented 7 years ago

The sample call does not compile:

Error   CS4033  The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.

The AsyncClient methods that returned Task were added from a 3rd party pull request and were not designed to work with the async keyword. You are welcome to add a pull request to support the async keyword.

kuskmen commented 6 years ago

@BrianNichols , hi I might be interested in doing such pull request but I might be needing a bit more info. For instance, same call does compile for me. Maybe some clear requirements of what needs to be done would be a nice start for me.

BrianNichols commented 6 years ago

The current AsyncClient implementation uses lower level pooled SocketAsyncEventArgs with a callback API. A previous pull request was accepted that added optional async Task based methods that sit on top of the async callback API.

Some people would prefer to use a different higher level async API that is compatible with the async/await keywords. The requirements are to provide new async/await compatible methods that also sit on top of the existing async callback API (if that is possible).

kuskmen commented 6 years ago

@BrianNichols Very well then, I will see what I can do. To me it sounds easy as just wrapping the execution into task but we will see how it goes.