Query Error when port 6030 map to external network - tdengine

Query error with C# Connector when port 6030 map to external network . while is run well within the local area network.
Steps to reproduce the behavior:
Map port 6030 to external network
Ttry to query data pass the external port
query error happen
Screenshots:
OS: [e.g. CentOS 7.9]
TDengine Version 3.0.16

Related

Ec2 instance opened port not connecting from certain regions

I have installed SQL Server in an AWS instance (Ubuntu) and it is working perfectly but found that it is not able to connect to the database from certain IPs (from that region not working for any ISPs). My port 1433 is open and I am able to access it from my system. Here is my security group configuration:
But in my friends system which is in a different network it is not connecting though I can access port 80 from that system. I telnet that port (1433) and it is throwing "could not connect host". I tried tracetcp and after 9 hops the requests are timed out. I used VPN in that system and it got connected.
Not able to determine what could be the issue. Not a network pro and any help is highly appreciated.

How does .NET Core on Linux determine what port a SQL Server instance listens on?

I have an ASP.NET Core 1.1 Web API which runs in a Docker container on Ubuntu and connects out to a SQL Server database (SQL Server 2012 SP3) on a Windows server. This works in 3 out of 4 of out environments, but in one environment it cannot connect to the SQL Server and I am trying to troubleshoot it.
The error is:
Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)
The SQL Server has an instance name: SQLSERVER1\APPS. From the Linux server I can ping the server SQLSERVER1 and telnet to SQLSERVER1 1372 (1372 is the port for the APPS instance: so network connectivity is there.
The only space I can see for the problem to occur is how .NET Core translates the instance name to a port number. Does anyone know how this is done and whether it is configurable on the client machine?
Remote named instance listening port discovery relies SQL Server Browser Service and protocol. As you cannot leverage this for your Linux docker image, I suggest you connect by explicitly specifying the port and omitting the instance name: "server=tcp:SQLSERVER1,1372;database=...;...":
The name or network address of the instance of SQL Server to which to connect. The port number can be specified after the server name: server=tcp:servername, portnumber
BTW if you live the instance name it should make no difference whatsoever after you explicitly specify the port.
PS. After reading again the question, the issue is related but different cause. Normally the Linux container can discover the Windows SQL Server, as the Browser service is probably up and running (proof that 3 envs. it works). In the 4th environment it means something blocks the discovery. Either the Browser service is stopped, or the browser discovery protocol listening port is blocked in the FW (UDP 1433), or perhaps the UDP packet (or the response!) is lost somewhere between the container and the server. You can investigate and find the root cause, but, you can also just ignore the problem and work around the issue by... specifying the port explicitly, just as I showed.

What would prevent code running in a Docker container from connecting to a database on a separate server?

I have a .NET Core 1.1 app running in a Docker container on Ubuntu 14.04, and it fails to connect to the SQL Server database running on a separate server.
The error is:
Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 25 - Connection string is not valid)
I have deployed the same image with the same command line on another Ubuntu 14.04 server, and it connects fine.
A console app running on the problem server (outside of Docker) can connect with the same connection string.
As far as I can see from the documentation, an app running in a container has access to the external network by default, so what could be blocking this connection?
an app running in a container has access to the external network by default
It could have access only if a valid IP address is assigned to the container. Sometimes the IP which Docker choose for the container can conflict with external networks.
By default, containers run in bridge network, so look at it:
docker network inspect bridge
Find the container and check its IP.
To resolve conflicts, it is possible to customize bridge network and set bip parameter to change the network's IP range (config file location depends on host's OS):
"bip": "192.168.1.5/24"
Or create a new docker network.
Or experiment with net=host option: docker run network settings
Does this help?
Connect to SQL Server database from a docker container
Also, Googling this "docker connect to sql server database" seems to return a lot of helpful results.

Connecting to SQL Server with .Net code on OS X

I am trying to port a web api that acts as a front-end for an SQL Server database. The web api works fine under Windows and when deployed to IIS, works from .Net Core on Windows, but gives a connection error when ran from within OSX or Linux.
The connection string that worked from within Visual Studio in Windows was
connectionString="data source=A\B;initial catalog=C;
persist security info=True;user id=X; password=Y;
MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient"
which is then translated into the connection string for the .Net core variant as:
Server=A\B;Database=C;user id=X;password=Y;
The project compiles fine, even works under .Net core in Windows, but crashes when run from a *nix machine.
The error is:
Unhandled Exception: System.Data.SqlClient.SqlException:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: TCP
Provider, error: 35 - An internal exception was caught) --->
System.AggregateException: One or more errors occurred. (No such device
or address) --->
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No
such device or address
I can ping the address, but I guess the combination of valid address (A) and server instance (B) does not work with a simple slash under *nix.
Server=A\B;Database=C;user id=X;password=Y;
says that you are accessing to B instance on a Windows machine whose Netbios name is A. Probably the windows machine where it worked was "A" itself.
For a remote connection though there are things that you should have done:
The SQL server instance should be set to allow remote connections.
The port on SQL server listens to must be enabled for access on firewall.
Instead of Netbios name, it is better to use IP address, along with port number if it is not the default port (1433).
You may start trying (where 1.2.3.4 is the windows machine's IP):
1.2.3.4\B;Database=C;uid=X;pwd=Y
For a detailed installation and setup of SQL Express on host PC, enabling for remote access and then accessing from remote computer, you may watch my short video series. Those videos were about installation of my application but most of it contains installing MS SQL server and accessing from remote location. It is a 4 parts series and here is the link to first part:
AccuSQL Installation 1/4

Socket server not accepting clients from other computers (connect failed: 10060)

I am trying to use this c socket class, but it only works when I use it on my own computer.
Desktop only
Server is started like this: cSocketServer -p:2030 -i:192.168.178.22
Client connects: cSocketclient -p:2030 -s:192.168.178.22
Works fine.
Desktop server, laptop client
Server: cSocketServer -p:2030 -i:192.168.178.22
Client: cSocketclient -p:2030 -s:192.168.178.22
Exact same as above, but this fires the connect failed: 10060 error. Which essentially means it timed out.
Desktop only (external address)
Server: cSocketServer -p:2030 -i:192.168.178.22
Client: cSocketclient -p:2030 -s:xx.xx.xx.xx
Where xx.xx.xx.xx is my external ip address.
Same error: connect failed: 10060. Port 2030 is definitely open and accessible, because I tested it with a few unrelated applications that allow their users to choose their own ports (like utorrent). While those run, whatismyip.org states port 2030 is open. But when I run my application it sais it Timed-out. Those applications do not have any special privileges in the firewall.
But even if I did mess up some firewall/router settings (which I'm fairly sure I didn't) that wouldn't explain why I can't connect to the server from within my local network. Other services (such as file sharing) work fine so there is definitely a connection between the 2 computers.
Both client and server run on windows 7 64-bit.
Also; for some reason, each client that connects gets their own inbound port assigned or something? Is that normal? When clients connect the server states;
Accepted client: 192.168.178.22:55156
Accepted client: 192.168.178.22:55164
Accepted client: 192.168.178.22:55176
What's that all about?
If two TCP connections have the same source IP, destination IP, source port, and destination port, there would be no way to tell them apart. To ensure they differ somewhere, clients typically assign a unique source port to every outbound connection they make.
As for the errors, you really need to do some troubleshooting. Do the listening sockets show up in a 'netstat'? Do you get the same problem with the firewalls turned off? Are the server and client on the same LAN (for the internal address case)? Is port forwarding enabled and working in the router (for the external address case)?
My bet is that the external address case won't work because you haven't configured the port to be forwarded by your router or your router doesn't support hairpin (local access to external IP). Other programs may work because they support UPnP or don't rely on hairpin (all access to external IPs come from outside your LAN).
I have no immediate explanation for why your desktop-to-laptop won't work inside your LAN. Are you sure both computers are in the same LAN? Can they ping each other?
Get rid of the -i argument to the server, or specify 0.0.0.0 and fix the code so that isn't considered an error, which is itself an error.

Resources