Getting org.apache.solr.client.solrj.SolrServerException: Server refused connection - solr

I have installed Apache Solr 8.2 in a Ubuntu 18.4 LTS machine. I was able to create multiple cores which are all having data driven schema configuration. I have opened 8983 port. I was able to access to URL from my local server and was able to index data into my Solr core.
Now I have a job running on a Tomcat server that runs on the same machine as the Solr server. When I try to connect to the Solr server and try to index data, I get the following exception:
org.apache.solr.client.solrj.SolrServerException: Server refused connection
I do not understand why this error occurs as the connection attempt is made from within the same machine. Also I do not have any issue when I try to connect to the core from my local server.

Related

How to connect a .NET API to a SQL Server database both in the same Kubernetes cluster?

I have a SQL Server running in a pod and an API running in another pod in the same cluster deployed with helm.
I'm able to connect to the database with a port forward and I created a user using Microsoft SQL Server Management Studio.
I point out that it's for a development environment and all is ok in production (production databases are outside the cluster).
When my API is deployed, this error is thrown in his pod :
An error occurred seeding the DB.
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
And
An error occurred using the connection to database 'dbdev' on server '127.0.0.1,1433'.
I wonder which connection strings to put in order to connect to the database because with that connections strings, it doesn't work :
"Server=tcp:127.0.0.1,1433;Initial Catalog=dbdev;Persist Security Info=False;User ID=xxxxxx;Password=xxxpasswordxxx;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=True;Connection Timeout=30;"
If it's a problem of connection strings, isn't localhost point inside my cluster ? or am I out of step.
Ok i found out my problem, i dont have to put IP address in my connection strings but the name of the service in the cluster.
"Server=service-name-in-cluster,1433;Initial Catalog=dbdev;Persist Security Info=False;User ID=xxxxxx;Password=xxxpassxxxx;MultipleActiveResultSets=False;Encrypt=False;TrustServerCertificate=True;Connection Timeout=30;"
This error message indicates that the .NET API is unable to establish a connection to the SQL Server database. There could be a few reasons why this is happening:
Incorrect server name or port: Make sure that the database host and
port specified in the API's configuration are correct. You can verify
this by checking the name and port used in the SQL Server Deployment
and Service.
Network connectivity: Ensure that the .NET API and SQL Server are in
the same network and can communicate with each other. You can use
kubectl exec to run a ping command from the API pod to the SQL Server
pod to test the connectivity.
Firewall rules: Make sure that the SQL Server port is open and
accessible from the .NET API. If you're using a firewall, you may
need to add a rule to allow traffic on the SQL Server port.
Incorrect credentials: Make sure that the credentials specified in
the API's configuration are correct and match the credentials used by
the SQL Server.
SQL Server instance not running: Check that the SQL Server instance
is running and accessible. You can do this by checking the status of
the SQL Server pod in the cluster and making sure that the SQL Server
service is running.
If the issue persists, you may need to inspect the logs of the API pod and the SQL Server pod to gather more information about the problem.

Error while connecting tomcat application from redhat to sql server

I have hosted my tomcat application built in Spring Boot to RedHat server. And my SQL Server is installed on Windows Server 2012r2. While running application, I am getting following error:
27-May-2019 00:00:04.420 SEVERE [pool-47-thread-1]
org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create
initial connections of pool.
com.microsoft.sqlserver.jdbc.SQLServerException: The driver could not
establish a secure connection to SQL Server by using Secure Sockets
Layer (SSL) encryption. Error: "Server chose TLSv1, but that protocol
version is not enabled or not supported by the client.". .......
I tried installing self signed certificate in RedHat, but no luck.

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.

Enabling SQL Server TCP/IP protocol with Tomcat v7

I'm working on Spring project using Tomcat as server, My database in SQL Server 2008 r2. whenever I enable the TCP/IP protocol of SQL Server, if I restert the Tomcat Server it gives me this error:
Starting Tomcat v7.0 Server at localhost' has encountered a problem
Server Tomcat v7.0 Server at localhost was unable to start within 45
seconds. If the server requires more time, try increasing the timeout
in the server editor.
I tried to inrease in start time but I encountred the same problem. If disable the TCP/IP protocol of SQL Server and I restert the Tomcat Server it works.
Best regards.

Resources