Connect to a remote sql server using stunnel

  • Hello everyone,

    I am trying to connect to a remote sql server using stunnel. I have already configure the stunnel.conf file on both side.

    When I am connect to the remote SQL Server, I am getting the following error:

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

    My remote server is configured to accept unlimited connections.

    Any suggestions or ideas?

    Thank you

  • I'm not too familiar with stunnel but you could check your logins on the instance. Does the specified login have the required permissions?

    Andrew

  • Thank you for your reply

    The login has the proper permission.

    I forgot to mention that I was able to connect to the remote SQL server from within our network.

    From outside the network, I am getting the error. I can telnet to the SQL server.

    Also the network administrator is telling me that there is no firewall blocking incoming traffic to the specified port.

  • Are you using a SQL Server authenticated account to login?

  • Yes I am

  • OK, as you can connect to the instance within the network the problem is not there.

    Have you tried specifying the port in the connection to the instance?

  • Yes I have tried,

    Basically, Stunnel allows you to encrypt the TCP connection between the client and the SQL server using SSL. On both side, you install stunnel and configure it.

    Client side

    Accept connection on 127.0.0.1:1433

    Connect to x.x.x.x:443 (x.x.x.x being the external ip address of the SQL server, and 443 being the only open port to the SQL Server)

    Server Side

    Accept all incoming connection on 443

    connect to 127.0.0.1:1433

    From the client side, you open SSMS and connect to 127.0.0.1, and stunnel redirect the traffic to 127.0.0.1:1433 on the SQL Server

  • If you can connect to the instance from the client side with SSMS then the problem must be with stunnel.

    Sorry I'm not familiar with stunnel.

  • When both machines belong to the same network (replacing the x.x.x.x with the internal IP address of the SQL server), I have no problem connecting to the SQL server through Stunnel. However, when the client is outside our network, I am getting the error.

    Anyway, thank you for your help.

  • Same error when connecting in SSMS?

  • Yes

  • In the SQL Server Configuration Manager, is TCP/IP and Names Pipes enabled for remote connections?

    If they have recently be changed the instance will also need to be restarted.

  • Both TCP/IP and Names Pipes have been enabled in the SQL Server

  • Alright this is starting to bug me now.

    Can you have a look at the Windows Firewall settings on the server running SQL?

  • Sorry! Just realised that the firewall won't be the problem.

    Try connecting again and have a look at the SQL Server error logs and the application/system event logs.

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply