Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OData] Synchronous operations are disallowed #860

Closed
tusmester opened this issue Jan 14, 2020 · 0 comments
Closed

[OData] Synchronous operations are disallowed #860

tusmester opened this issue Jan 14, 2020 · 0 comments
Assignees
Labels
Milestone

Comments

@tusmester
Copy link
Member

@tusmester tusmester commented Jan 14, 2020

In an Asp.Net Core environment synchronous stream reader/writer operations are not allowed by default. The first roadblock is in ODataMiddleware.Read method, when calling an action.

ODataException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
Inner Exception:
InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
   at Microsoft.AspNetCore.Server.IIS.Core.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Read(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadToEnd()
   at SenseNet.OData.ODataMiddleware.Read(Stream inputStream)
   at SenseNet.OData.DefaultActionResolver.GetMethodBasedAction(String name, Content content, Object state)
   SenseNet.ApplicationModel.ActionFactory.CreateAction(String actionType, Application application, Content context, String backUri, Object parameters, Func`4 getDefaultAction, Object state)

The workaround is to allow these operations during app start:

// using Kestrel:
services.Configure<KestrelServerOptions>(options =>
{
    options.AllowSynchronousIO = true;
});

// using IIS:
services.Configure<IISServerOptions>(options =>
{
    options.AllowSynchronousIO = true;
});
@tusmester tusmester added this to the Sprint 201 milestone Jan 14, 2020
@kavics kavics self-assigned this Jan 16, 2020
@herflis herflis modified the milestones: Sprint 201, Sprint 202 Jan 22, 2020
@tusmester tusmester closed this Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.