requested address is not valid in its context

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
developer123
Posts: 4
Joined: Thu 21 Sep 2017 14:50

requested address is not valid in its context

Post by developer123 » Thu 21 Sep 2017 15:13

Hello Devart and users,

I use dotConnect Mobile in a VB.Net Project, running on WindowsMobile 6.5.3, with a connection to a PostgreSQL 8.3.8 database running on Win2003 Server.
I use a simple code for connection:

Public myConnstring As String = "host=192.168.178.66;User Id=admin;Password=123;Database=mydb;Port=5432;"
Public WithEvents myPgSqlConnection As Devart.Data.PostgreSql.PgSqlConnection
myPgSqlConnection = New Devart.Data.PostgreSql.PgSqlConnection
myPgSqlConnection.ConnectionString = myConnstring
myPgSqlConnection.ConnectionTimeout = 200
myPgSqlConnection.Open()

Everything works fine, if my Mobile-Device is directly connected to the Server over USB.
If I connect the Mobile-Device over WLAN I get the exception:
Devart.Data.PostgreSQL.PGSqlException: the requested address is not valid in its context

The WLAN-Connection works, I can ping the Server, connect to the internet and so on.
My Device has a IP-V4-Adress containing to the same Network.

Thanks a lot for your help!

developer123
Posts: 4
Joined: Thu 21 Sep 2017 14:50

Re: requested address is not valid in its context

Post by developer123 » Mon 25 Sep 2017 13:25

I now tested my connection with the sample-projects from Devart.
Maybee it's helpful that I get the following Exception with the DataTable-Sample:

PgSqlException: unable to read data from the transport connection; an existing connection was forcibly closed by remote host

What to do?
Thanks a lot for your help!

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: requested address is not valid in its context

Post by Pinturiccio » Tue 26 Sep 2017 15:43

developer123 wrote:Devart.Data.PostgreSQL.PGSqlException: the requested address is not valid in its context
Please make sure that your device is in the same local network as the server. Please also ping your device from the server to find the device IP as seen by the server. Then add the corresponding record to the pg_hba.conf file. For more information, please refer to https://www.postgresql.org/docs/8.3/sta ... -conf.html

Please also describe how you ping the server from your device.
developer123 wrote:I now tested my connection with the sample-projects from Devart.
Do you run the sample from your device or from a computer via Device Emulator?

Maybe your device connects to the computer not via the local network but via the Internet, and it doesn't know the 192.168.178.66 IP address. Look through the following thread, maybe you will find something useful in it:
https://social.msdn.microsoft.com/Forum ... ?forum=wcf

developer123
Posts: 4
Joined: Thu 21 Sep 2017 14:50

Re: requested address is not valid in its context

Post by developer123 » Wed 27 Sep 2017 08:22

Thank you for the answer.

The device is in the same subnet as the server. The server can also ping the device.
pg_hba.conf is configured so that all devices from this subnet have full access to the database.

I run the Devart Ping-Sample from the device with Windows Mobile 6.5.3. It works fine.

The device is in the same subnet as the server, so it knows the IP and does not connect via Internet.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: requested address is not valid in its context

Post by Shalex » Thu 28 Sep 2017 15:58

1. Please add "protocol=2;" to your connection string. If the text of the error is different in this case, specify it.

2. Confirm that you are using the newest (7.9.980) build of dotConnect for PostgreSQL Mobile.

3. If possible, restart both a mobile device and a workstation with PostgreSQL Server. Does this make any difference?

developer123
Posts: 4
Joined: Thu 21 Sep 2017 14:50

Re: requested address is not valid in its context

Post by developer123 » Mon 02 Oct 2017 14:53

Thank you very much for your effort.
You were right, there was a fault in the pg_hba.conf because of the used subnet!

Many thanks to all!

Post Reply