#Unable to connect to MSSQL container through TCP Proxy

76 messages · Page 1 of 1 (latest)

patent vessel
#

I was able to build and run a SQL Server database through a Dockerfile, exposing the standard port and providing the proper build arguments but am unable to connect after setting up a TCP Proxy (since this is a Docker-based deployment and not a supported Database Service it doesn't have a connection string if I understand right).

The error I first receive when trying to connect from SQL Server Management Studio is:
Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

I also receive the error:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) (Framework Microsoft SqlClient Data Provider)

Is this a TLS issue? I've tried various combinations of encrypt and trust server certificate parameters but to no avail.

lament cairnBOT
#

Project ID: 664eb8d7-2ff0-44d3-a9ab-537fd41b5746

glass waspBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

patent vessel
#

664eb8d7-2ff0-44d3-a9ab-537fd41b5746

brittle dome
#

any reason for trying to deploy your own mysql service instead of railway's provided mysql template?

patent vessel
#

MSSQL = SQL Server

#

If it was MySQL I would've absolutely gone with a template. I'm mostly trying to avoid the pain that is Azure.

brittle dome
#

oh yeah sorry my bad

#

can you link me the docker image you are using to deploy a mssql server and I will see if I can get a template up and running for you

patent vessel
#

Hi Brody, sorry I forgot about this! Here is my Dockerfile:

FROM mcr.microsoft.com/mssql/server:2019-latest

ARG ACCEPT_EULA
ARG MSSQL_SA_PASSWORD

# Default SQL Server TCP/Port.
EXPOSE 1433

# Run SQL Server process.
CMD [ "/opt/mssql/bin/sqlservr" ]
brittle dome
#

does that run a windows based image?

patent vessel
#

mcr.microsoft.com/mssql/server:2019-latest is an ubuntu-based image

brittle dome
#

I assume you do have the EULA and password variables set?

patent vessel
#

Yes

brittle dome
patent vessel
patent vessel
#

Connection Details

#

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

brittle dome
#

screenshot of the public networking section of your service settings please

patent vessel
brittle dome
#

I honestly have no clue, try the other ports in the logs 1434, 1431

patent vessel
#

hmm you mean like EXPOSE those ports as well in the Dockerfile, as well as TCP proxy them, then try it?

brittle dome
#

the expose keyword does absolutely nothing on railway, I'm talking about with the tcp proxy

patent vessel
#

OK will give it a shot

brittle dome
#

something else that just popped into my mind, are you perhaps on a public network? they could be blocking non standard ports such as 29343

patent vessel
#

I'm at home, should be ok in that regard I think? 1433, 1434, 1431 all had the same error message

#

Error changes to:

The client was unable to establish a connection because of an error during connection initialization process before login. Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server. (provider: SSL Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

when changing connection parameter Encrypt to "strict"

brittle dome
#

I'm back to being out of ideas 😦

patent vessel
#

I don't see anything in the logs. Oh well, appreciate your help regardless. Was hoping to make this work to save some money and headache working with Azure.

brittle dome
#

I'll give this a try myself when I'm home

brittle dome
#

it worked!

patent vessel
#

Nice! What did you do differently?

brittle dome
#

uh idk, set the three variables the image wants and connected to it with dbgate

patent vessel
#

I only set two, accept_eula and sa_password. Can you share your Dockerfile?

#

Looks like you used SQL server 2022 image?

brittle dome
#

i dont use a dockerfile, but i did use the latest tag

#

if i where to use a dockerfile id use this

FROM mcr.microsoft.com/mssql/server:2019-latest

this would be the entire dockerfile, this one single line is all thats needed

patent vessel
#

How did you not use a Dockerfile? Is Microsoft SQL a database option now? I think when I last tried this months ago it wasn't which is why I went with docker

brittle dome
#

i deployed the image directly

patent vessel
#

I'm guessing there is an option to do that when setting up a new project?

brittle dome
#

no, the dashboard doesnt let you deploy an image from mcr, but thats besides the point

patent vessel
#

Lol I don't follow. How do I go about recreating what you did?

patent vessel
#

But if I understand, you're saying you deployed an image directly but I can't do that bc it's an MCR image?

brittle dome
#

correct

patent vessel
#

What can I do differently? Add that third variable?

#

I can use latest tag as well, I'm not pinned to 2019

brittle dome
patent vessel
#

Are you thinking this is a networking thing on my end?

brittle dome
#

not sure, try dbgate, its free

patent vessel
#

I was using Azure Data Studio to test connection previously. I'll try dbgate

#

Alright I'll try the 1 line Dockerfile, add the missing variable you have, and connect w dbgate and get back to you

brittle dome
#

i omitted the variable and it still worked for me

patent vessel
#

Can I also try connecting to yours and see if it works?

brittle dome
#

sure, but does that mean dbgate wasnt working for you either?

#
roundhouse.proxy.rlwy.net:39537
sa
MK$!Q5tr+LS#AZgeq6&HjFcz7Rkvma4h
patent vessel
#

Haven't got to the computer yet

#

Starting it now

#

While installing dbgate I was able to connect with azure data studio to yours

brittle dome
#

are you using the dockerfile I gave you?

patent vessel
#

Yes, just updated the repo and railway redeployed

#

Aaaand I'm connected

#

The one-line Dockerfile vs my original was the difference

brittle dome
#

awesome

patent vessel
#

This could be big! Railway already hosts an API for an azure SQL DB that costs the local govt I work for hundreds a month.

#

If I can replace that DB and colocated it with the API on railway, thats a financial and security win to me

#

Thanks a bunch man, really appreciate your help

brittle dome
#

if only railway supported deploying images directly from mcr

#

deploying a database from a repo just sounds ugly

#

even if its using the same image in the end

patent vessel
#

Yeah I feel ya, a repo for one file with one line to create a DB haha

brittle dome
#

but the dashboard only supports deploying images directly from dockerhub, ghcr, and quay