无法从服务器2012R2连接到azure数据库

时间:2015-07-31 15:03:19

标签: vb.net azure windows-server-2012-r2

我们正在将所有站点从MS Server 2008迁移到Server 2012R2。问题出在特定网站上。某些页面使用连接字符串连接到客户端的azure数据库以访问其数据。几个星期前我们迁移了这个网站,没有任何问题。现在这些页面上出现了错误。错误是:

A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

我们的托管服务提供商做了更新,并推测是这种情况。但是,当回滚更新时,问题仍然存在。我在旧服务器上添加了一个临时站点,具有完全相同的代码,并且没有连接到azure db的问题。或者,新服务器上有一些变化,或者客户端有一些变化。这是我使用的代码:

        Dim sAzureDB As String = "Server=tcp:<address>.database.windows.net,1433;Database=<DBNAME>;User ID=<USERNAME>;Password=<PASSWORD>;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"

        Public Function GetDistinctDivisionGroup(Optional ByVal OGroupID As Integer = -1) As DataSet

            OpenConn("<Stored Procedure>", CommandType.StoredProcedure, sAzureDB)

            Dim oAdapter As New SqlDataAdapter
            Dim oData As New DataSet
            oAdapter.SelectCommand = oCmd

            oCmd.Parameters.Clear()

            If OGroupID > -1 Then
                oCmd.Parameters.Add("@OGroupID", SqlDbType.Int, 4).Value = OGroupID
            End If

            Try

                oAdapter.Fill(oData, "DistinctDivision")

            Catch ex As Exception
                Throw
            Finally
                KillConn()
            End Try

            Return oData
        End Function

        Private oConn As SqlConnection
        Private oCmd As SqlCommand


        Private Sub OpenConn(ByVal ThisCommandText As String, ByVal ThisCommandType As CommandType, Optional ByVal AlternateConnection As String = "", Optional ByVal UseRDB As Boolean = False)

            If UseRDB Then
                oConn = New SqlConnection(HttpContext.Current.Application("conString"))
            Else
                If AlternateConnection <> "" Then
                    oConn = New SqlConnection(AlternateConnection)
                Else
                    oConn = New SqlConnection(HttpContext.Current.Application("conRString"))
                End If
            End If

            oCmd = New SqlCommand()

            ' wait 60 seconds before timing out
            oCmd.CommandTimeout = 60

            oCmd.Connection = oConn

            ' the content is being edited
            oCmd.CommandText = ThisCommandText
            oCmd.CommandType = ThisCommandType

            ' now open the connection
            oConn.Open()

        End Sub

        Private Sub KillConn()
            RF.ConjunctionJunction.CleanUpTime(oCmd, oConn)
        End Sub

这是另一个处理连接的vb文件中的其他代码:

            Namespace RF

                Public Class ConjunctionJunction        
                    ''' <summary>
                    ''' Closes the connection and disposes of the command object passed in.
                    ''' </summary>
                    ''' <param name="CommandObject">The command object to clean up</param>
                    ''' <remarks></remarks>
                    Shared Sub CleanUpTime(ByVal CommandObject As System.Data.SqlClient.SqlCommand, _
                            ByVal ConnectionObject As System.Data.SqlClient.SqlConnection)

                        ' kill the connection
                        ConnectionObject.Close()
                        ConnectionObject.Dispose()
                        ConnectionObject = Nothing

                        ' kill the command
                        CommandObject.Dispose()
                        CommandObject = Nothing

                    End Sub

                End Class


            End Namespace

为什么上面的代码可以在Server 2008上运行而不在服务器2012R2上运行?

1 个答案:

答案 0 :(得分:0)

Have you tried enabling TLS 1.0 on your Server 2012R2 box?

http://azure.microsoft.com/blog/2014/10/29/protecting-against-the-ssl-3-0-vulnerability/

相关问题