Blazor WebSocket closed with status code 1006 - asp.net

I have made a Blazor app, which is working well locally. When I put it on the server, quite often (when app uses DB context) I get this error :
Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 ()
The user have to refresh the page, which is really annoying. You can't use app working in this way.
I have found a lot of discussions on this error, lot of plans...and almost everything is older than one year. I would expect the solution already, but haven't found anything.
Anyone knows, why is this happening and how to figure it out in the Blazor app? At least to catch this error and wait until the connection is back, so the page is not getting faded?
So far I was able to do only automatic reloading of page by javascript, when I get this error. But anyway, I can't use this solution in production, because the page is down for a second and it doesn't look good. I need to catch it before and keep the page active.
Thank you.

FYI , Have you check somewhere on the server-side like the logic that use data from DB context or the security/config in the production between IIS server and DB? If you are sure that it's come from the DB context then have you validate by test other possibility like make the test method that have long delay time/or mockup method that return the data to check whether the error still occur?
I once have a really stupid code in an object. but the code is build with no error. But it clash on runtime with no clue relate to the problem.
private string _oh;
public string oh
{
get { return _oh; }
set { oh= value; // cause infinite loop > should _oh
}
}
The worst part is that the error throwed is the same message as this question, So I quite sure there is the root clause elsewhere.
Error: Connection disconnected with error 'Error: WebSocket closed with status code: 1006 ()

Related

Having trouble connecting to iSeries from .NET Core

This is a follow-up from the following question: Having trouble connecting to iSeries from .NET Core
The initial problem was resolved by setting a port number. I'm now running into the problem of the connection seemingly opening, however, hanging on the actual .Open() step - IE, never continuing on to the next line of code. For reference, here's my code block:
public static DB2Connection GetDatabaseConnection(string connectionString)
{
DB2Connection DB2Connection = new DB2Connection(connectionString);
DB2Connection.SystemNaming = true;
try
{
DB2Connection.Open();
return DB2Connection;
}
catch (Exception ex)
{
throw ex;
}
}
And my connection string is in this format: Server=###.###.###.###:#####;Database=DATABASE;UID=USER;PWD=PASSWORD;LibraryList=LIBRARY,LIST
Looking at the logs on the i Navigator, I see that there is a job name Qzhqssrv when is opened, with the user Quser, status Running, and type Prestart batch - Server. Looking into the logs for that entry, I see Job #####/QUSER/QZHQSSRV started on DATE at TIME in subsystem QUSRWRK in QSYS. Job entered system on DATE at TIME. However, it doesn't seem to continue beyond that.
Looking at the logs for a similar operation, when I'm connecting via Access Client Solutions, I get considerably more information and more steps in the logs. This leads me to believe that the system is waiting for me to send further information, however, my application is still stuck on .Open() - so perhaps there is something else I was supposed to send as part of the .Open() instruction. If so, I'm not sure what it would be.
Any insights would be greatly appreciated. Thanks!
Just to close this topic out - the problem was indeed the lack of a license. Connecting on port 446 was the correct approach, and once we got a license, we were able to get the connection working. Thanks #nfgl!

Azure/Xamarin Mobile App Hangs at SyncContext.InitializeAsync

So, I had a working xamarin forms app that used azure mobile services. I upgraded the server side to use mobile app service and upgraded the nugets in my client to use the latest and greatest client codes.
I manually updated my test/ios simulator sqlite db to use the proper column names for the system properties since they dropped the double underscore prefix.
When I finally got it all built and tried to run in the ios 6/8.3 simulator it ran fine until it hit the InitializeAsync method. It doesn't throw (its in a try catch) and I let it run for a long time and it just sits there.
I then tried to change the db name so it would make it from scratch, which it did but still just hung. So I then tried to simplify it to a single table and took out my delegating handler so it was as basic as I could get it and it still just hangs.
Has anyone else had this problem? I am at a complete loss because I don't get an error. Not sure where to start.
Thanks.
Edit, code added:
var store = new MobileServiceSQLiteStore(_localDatabaseName);
store.DefineTable<Profile>();
try
{
await _mobileService.SyncContext.InitializeAsync(store);
}
catch (Exception e)
{
Debug.WriteLine(e.Message);
}
I also tried with ConfigureAwait(false) as suggested but it made no difference.
I set breakpoints in the catch and the code that immediately follows this block but they are never hit.
Ok, so I poked around a bit more and found some info on deadlocked threads answered by Stephen Cleary, the guru of async/await.
It turned me onto looking upstream. The call into my azure init code looked like this:
var azureService = Container.Get<IAzureService>();
azureService.InitializeAzync().Wait();
Which was in the constructor of the calling component.
So, I changed it to this:
try
{
Task.Run(() => azureService.InitializeAsync()).Wait();
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
And the SyncContext.InitializeAsync() call worked fine and continued on.
So, I don't really know the answer for this, I guess the internals of the new azure client do something differently than the old code since using Wait() was how I did it before and never had a problem. But there was some sort of threading deadlock. Very odd and took days to get past, now I have to fix the next deadlock I hit. If Stephen is out there and can offer some clarification that would be great.
Had this same issue - changing to a Task.Run and ConfigureAwait(false) did fix it.
Very odd thing is the same code worked fine with Mobile Services, but broke when we upgraded to Mobile App Services.

Connection pooling - closed connection issue

Problems:
I have a web app that is getting battered. Everything is working but I get about two errors a day I can not explain. It could be the first user hitting the system because the error appears in the error log intermittently it occurred today around 7:30 am in servers time zone (same as the users).
I fixed an old issue by implicitly destroying the connection by way of the using statement as it only marks the connection as recyclable.
Error Log:
Message: 3df8d62a-6b47-479e-b5d2-b23e0db92d92 : System.InvalidOperationException: Invalid operation. The connection is closed.
at System.Data.SqlClient.SqlConnection.GetOpenConnection()
at System.Data.SqlClient.SqlConnection.get_ServerVersion()
at System.Data.Linq.SqlClient.SqlProvider.get_IsServer2005()
at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
at xxxxx.Resources.Data.LINQ.DistrictService.GetDistrict(Int32 districtID)
Related Code:
//--------------------------------------------------------------------------------------------
public Domain.Data.District GetDistrict(int districtID)
{
using (_dataContext = new DistrictDataDataContext(_systemService.GetCurrentSystem().WriteOnlyDatabase.ConnectionString))
{
Mapper.CreateMap<District, Domain.Data.District>();
return (from s in _dataContext.Districts
where s.DistrictID == districtID
select Mapper.Map<District, Domain.Data.District>(s)).SingleOrDefault();
}
}
Note:
I think that this is a non-issue because the inherent behavior of the connection pooling might be firing a retry (this could just be information saying "hey we tried what you asked for but the connection was closed, we will now open one up it.") however, If this is the case, I do not get a confirmation of successful retry and I am not even sure would be expected. We have had no complaints and this cant be duplicated in house by our QA staff. I hope maybe someone else has come across this.

Why do I get exception "The execution of the InstancePersistenceCommand named LoadWorkflowByInstanceKey was interrupted by an error"

After doing some refactoring to my WF4 service, I got this exception when calling some of the operations:
The execution of the InstancePersistenceCommand named {urn:schemas-microsoft-com:System.Activities.Persistence/command}LoadWorkflowByInstanceKey was interrupted by an error.
My xamlx file contains a few receive/sendreplytoreceive pairs, as shown below. The exception sometimes happens on receive2, sometimes receive3.
receive1 (no correlation, cancreateinstance=true)
send reply to receive (initializes content correlation on generated ID)
receive2 (correlates on ID, cancreateinstance=false)
send reply to receive
receive 3 (correlates on ID, cancreateinstance=false)
send reply to receive
After doing a lot of debugging and making sure all correlations where set up right, the exception disappeared for new instances of the workflow.
What does the exception mean, and why did it show up and why did it dissappear all of a sudden? Is it a code/xamlx issue or something with the infrastructure (AppFabric/SQL)?
I'm hosting the WF service with IIS/AppFabric, using AppFabric' SQL persistence.
According to this support note this error can be the result of a race condition between the Receive and a Delay activity expiring. Is this possible in your workflow.
I kinda figured mine out... aparently if you point your persistance store in a SQL previous to 2012 you get the error... so all i had to do is put mine persistance store in a SQL 2012...
When I had this problem it turned out to be a mistake in my connection string when instantiating the persistence store object.
SqlWorkflowInstanceStore store = new SqlWorkflowInstanceStore(connStr);
I realise this an old question but fixing the connection string got rid of my error while running store.Execute() so I thought I'd share!

Error #3119: Database file is currently locked

I have developed to applications in flex. The one application constantly retrieves data from the internet, while the other can be opened and closed when you want, both apps use the same database. The problem is that at random I get an Error #3119: Database file is currently locked. Is it not possible to have two stable connections in a Adobe AIR environment? Anyone has any solutions?
I think not. Not at once.
I know this is a really old question, but I ran into this issue myself and found a solution for it for those who may come across this. I hope this helps someone, because I know for me, all I could find on this topic was false information, like that given by Konrad. You can, in fact have multiple open database connections. Actually, in my application, I have an asynchronous connection used for writing data to the database (INSERT, UPDATE, DELETE), and a synchronous, read-only connection for reading from the database. On the asynchronous connection, for every execute, I always get an immediate lock by putting all statements in a transaction using
conn.begin(SQLTransactionLockType.IMMEDIATE);
This will allow you to read from the database while writing to it with another connection. Where I ran into a problem is when trying to read from the database from one connection after committing this async statement and before it actually finished writing the data. So, even though the documentation for SQLTransactionLockType.IMMEDIATE states you can still do reads while it is locked, you actually cannot while another statement is actively in the process of writing data.
I got around this by writing my own execute for the synchronous connection. It simply tries to execute, and if it fails due to Error #3119, try again until you succeed. Between each function call, the data will continue to be written to the database and eventually will no longer be busy. Here is the code for that function:
public static function execute(stmt:SQLStatement):void {
try {
stmt.execute();
} catch (e:SQLError) {
if(e.errorID == 3119) {
execute(stmt);
} else {
trace(e.details + "\n" + e.getStackTrace());
if(stmt.sqlConnection != null && stmt.sqlConnection.inTransaction) {
stmt.sqlConnection.rollback();
}
}
}
}
Another gotcha to watch out for with this error (if you're an idiot like me anyway) is to check if you've got the SQLite db file open in a db browser, which can lock the database, and cause this error (and hours of googling and irritation).

Resources