-1

I have an Xamarin application that uses Entity Framework.

It works great on UWP however when on iOS if I lock the phone, then unlock minutes later I get the following error when loading data from or to the database:

Snix_Execute (provider: SNI_PN7, error: 35 - SNI_ERROR_35) Snix_Execute (provider: SNI_PN7, error: 35 - SNI_ERROR_35)

With an inner exception of:

Unable to write data to the transport connection: The socket has been shut down.

I think it's to do with iOS closing the connection as part of cleanup but how do I reopen the connection? What other information can I provide to help solve this issue? I know I can use the OnResume method to reopen the connection but what's the code to actually reopen the connection?

Ryan Gaudion
  • 695
  • 1
  • 8
  • 22
  • Review the backgrounding tasks/events : "Performing Tasks During DidEnterBackground" : https://learn.microsoft.com/en-us/xamarin/ios/app-fundamentals/backgrounding/ios-backgrounding-techniques/ios-backgrounding-with-tasks – SushiHangover Nov 08 '19 at 16:02
  • Okay thanks for that. The only things is, I don't know what commands I need to run? – Ryan Gaudion Nov 08 '19 at 16:05
  • 1
    You can reopen the connection in the [OnResume](https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/app-lifecycle#lifecycle-methods) method. You only have few minutes to handle background tasks in iOS. – nevermore Nov 11 '19 at 07:26
  • Does this answer your question? [Entity Framework - How to clear connection pool manually? SNIX\_Excecute Error](https://stackoverflow.com/questions/58800868/entity-framework-how-to-clear-connection-pool-manually-snix-excecute-error) – Ryan Gaudion Jan 20 '20 at 16:56

1 Answers1

0

EDIT:

The issue was todo with pooling meaning that the connections were basically being cached even though when the phone turned off, they were closed. To overcome this you can either turn of pooling in the connection string by adding Pooling=False; to the string:

Post

Or clear the pools everytime that the app wakes up on the OnResumeMethod:

SqlConnection.ClearAllPools();

Post

Ryan Gaudion
  • 695
  • 1
  • 8
  • 22