Tuman Sahu

Tuman Sahu

  • 1.4k
  • 293
  • 9.2k

SocketException: when connection through mysql

Feb 11 2020 4:17 AM
Hello friends,
 
I want to create a connection between mysql remote server and asp.net
 
Where database server information is as follows
  • Server: Localhost via UNIX socket
  • Server type: MySQL
  • Server version: 5.7.26-0ubuntu0.16.04.1 - (Ubuntu)
  • Protocol version: 10
  • User: root@localhost
  • Server charset: UTF-8 Unicode (utf8)
my webconfig code is as follows
 
<connectionStrings >
<add name ="rtd" connectionString ="server=192.168.x.x; port=8090; Integrated Security=False; Initial Catalog=rtu; User Id=root; Password=123;" providerName ="MySql.Data.MySqlClient"/>
</connectionStrings>
 
In code behind on page load 
 
Dim str As String = ConfigurationManager.ConnectionStrings("rtd").ConnectionString
Dim conn As MySqlConnection = New MySqlConnection(str)
Dim cmd As MySqlCommand = New MySqlCommand("SELECT * FROM realtime order by id desc limit 1")
Dim da As MySqlDataAdapter = New MySqlDataAdapter()
cmd.Connection = conn
da.SelectCommand = cmd
Dim dt As DataTable = New DataTable()
da.Fill(dt)
rtgrid.DataSource = dt
rtgrid.DataBind()
 
when is am execute following code  socket exception occurs and error is below
 
SocketException: A connection attempt failed because the connected party did not properly respond after a period
of time, or established connection failed because connected host has failed to respond
  
can anyone suggest me where I am wrong?

Answers (2)