Hybrid Connection error with SQL Server: System.OverflowException: Arithmetic operation resulted in an overflow

Problem

If you are trying to use Azure Hybrid Connections to access SQL Server then be advised that an update on May 10, 2016 to .NET may cause connections to fail.  When it fails you will see errors that look like this

Exception: System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.OverflowException: Arithmetic operation resulted in an overflow. at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(SqlAuthenticationMethod authType, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable, Boolean& fedAuthRequired)

or (64 bit Web app)

System.OverflowException: Array dimensions exceeded supported range, at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake

 

Workaround

UPDATE:  The new version of Azure App Service Hybrid Connections is what you should use now: https://docs.microsoft.com/en-us/azure/app-service/app-service-hybrid-connections

Yes there still a fix scheduled but it is at least a couple of months out and the Classic Hybrid Connections are now deprecated.

 

We are working to update the Hybrid Connection Manager to fix this issue but in the meantime the problem can be worked around by following the instructions here:  https://support.microsoft.com/en-us/kb/2643584  Again, this is a short term workaround until we can get the updated Hybrid Connection Manager released.

This is not an arbitrary advisement for all Hybrid Connection customers to follow.  If your endpoint is working then do nothing.  If your endpoint is an SQL Server and it’s working, then I assume you haven’t updated your OS and you will see things fail with your next OS update.

If it is broken after the updates on May 10 then apply the work around.

 

WARNING from the above kb article:

 

It will be up to you to re-apply this update after the Hybrid Connection Manager is fixed. I will update this blog when the new Hybrid Connection Manager is available!

 

The instructions need to be followed on hosts running the Hybrid Connection Manager.  The instructions for directly editing the registry are:

To add this schannel registry entry registry entry, follow these steps:

1.Click Start, click Run, type regedit in the Open box, and then click OK.

2.Locate and then click the following subkey in the registry:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\SecurityProviders\SCHANNEL

3.On the Edit menu, point to New, and then click DWORD Value.

4.Type SendExtraRecord for the name of the DWORD value, and then press Enter.

5.Right-click SendExtraRecord, and then click Modify.

6.In the Value data box, type 2 to disable the split record in schannel, and then click OK.

7.Exit Registry Editor.

8. Restart the Azure Hybrid Connection Manager Service or reboot the machine the Azure Hybrid Connection Manager Service is installed on (see the security update to determine which is required, or reboot the machine to be safe)

Make sure that if you copy/paste the key name you don’t accidentally put a space in at the end.

Make sure you name the DWORD “SendExtraRecord

Make sure the DWORD was set to 2.

 

Note

If this does not resolve the issue, please open a support case through your Azure Support Portal to engage us further!