Skip to content

Expected to read 4 header bytes but only received 0 #1158

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

Closed
Andyyy777 opened this issue Apr 6, 2022 · 1 comment
Closed

Expected to read 4 header bytes but only received 0 #1158

Andyyy777 opened this issue Apr 6, 2022 · 1 comment

Comments

@Andyyy777
Copy link

Andyyy777 commented Apr 6, 2022

Software versions
MySqlConnector version: 2.1.7
Server type (MySQL, MariaDB, Aurora, etc.) and version: MySQL 5.0.37
.NET version:
(Optional) ORM NuGet packages and versions:
Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4465.0

Describe the bug
I was using MysqlConntor to build the sphinx server connection for my website. The website and sphinx connection worked normally when I was running the tests on local. However, after the website getting published, I got this error when I was trying to get access to it.

Exception
Source error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[EndOfStreamException: Expected to read 4 header bytes but only received 0.] System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.ConfiguredValueTaskAwaiter.GetResult() +51 MySqlConnector.Protocol.Serialization.<g__AddContinuation|5_0>d.MoveNext() +594 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.ConfiguredValueTaskAwaiter.GetResult() +51 MySqlConnector.Core.d__93.MoveNext() +1555 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.ConfiguredValueTaskAwaiter.GetResult() +51 MySqlConnector.Core.d__83.MoveNext() +10750 [MySqlException (0x80004005): Couldn't connect to server] MySqlConnector.Core.d__83.MoveNext() +15057 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 MySqlConnector.Core.d__21.MoveNext() +758 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.ConfiguredValueTaskAwaiter.GetResult() +51 MySqlConnector.Core.d__10.MoveNext() +3544 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 MySqlConnector.Core.d__10.MoveNext() +4687 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.ConfiguredValueTaskAwaiter.GetResult() +51 MySqlConnector.d__124.MoveNext() +922 [MySqlException (0x80004005): Connect Timeout expired.] MySqlConnector.d__124.MoveNext() +2415 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 System.Runtime.CompilerServices.ConfiguredValueTaskAwaiter.GetResult() +51 MySqlConnector.d__26.MoveNext() +1636 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +32 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +62 MySqlConnector.MySqlConnection.Open() +61 WebControlPanel.Functions_Global.getAllConfigKeys(String connectionString) in E:\TDC_VS\Common\Functions_Global.vb:1100 WebControlPanel.Functions_Global.InitConfigManagerProperties() in E:\TDC_VS\Common\Functions_Global.vb:1145 WebControlPanel.Startup.Configuration(IAppBuilder app) in E:\TDC_VS\WebControlPanel\Startup.vb:11 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +132 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146 Owin.Loader.<>c__DisplayClass19_1.b__0(IAppBuilder builder) +93 Owin.Loader.<>c__DisplayClass9_0.b__0(IAppBuilder builder) +224 Microsoft.Owin.Host.SystemWeb.OwinAppContext.Initialize(Action1 startup) +897 Microsoft.Owin.Host.SystemWeb.OwinBuilder.Build(Action1 startup) +51 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +101 System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +139 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +584 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369 [HttpException (0x80004005): Exception has been thrown by the target of an invocation.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +724

Expected behavior
The target website can be clearly loaded and reachable.

Additional context
I see a similar problem in issue #540
Thank you so much for all the help :)

@Andyyy777 Andyyy777 reopened this Apr 7, 2022
@bgrainger
Copy link
Member

The outermost exception seems to be your real problem:

MySqlException (0x80004005): Connect Timeout expired.

It looks like MySqlConnector can't establish a connection to your database server. Check your firewall rules, etc., and make sure your application server can reach your database. Different network access rules would also explain why it "worked normally when I was running the tests on local" but failed in production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants