B4J Question Connection to http://192.168.0.100:51042 refused

Status
Not open for further replies.

JOTHA

Well-Known Member
Licensed User
Longtime User
Hello Forum,
this belongs to this Tutorial:
[url]http://www.b4x.com/android/forum/threads/server-data-collection-solution-device-desktop-and-web-reports.37254/#post-221756

I did everything described above and also told the firewall to open the port 51042, but it doesn't work.[/URL]
... and here is the error message:
Program started.
org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.0.100:51042 refused
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:159)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:108)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:415)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at anywheresoftware.b4a.http.HttpClientWrapper.executeWithTimeout(HttpClientWrapper.java:310)
at anywheresoftware.b4a.http.HttpClientWrapper.access$0(HttpClientWrapper.java:308)
at anywheresoftware.b4a.http.HttpClientWrapper$ExecuteHelper.run(HttpClientWrapper.java:207)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.0.100:51042 refused
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:75)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:157)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:391)
at java.net.Socket.connect(Socket.java:579)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:123)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:133)
... 15 more
Connection to http://192.168.0.100:51042 refused
I'm confused.
Can anyone tell me what the error could be?

Thank you in advance!
 

JOTHA

Well-Known Member
Licensed User
Longtime User
... but the DataCollectionDevice ... I have also changed:
Sub Globals
...
Private link As String = "http://127.0.0.1:51042"
This doesn't work.
ErrorMessage: "refused"

Here is the LOG:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:51042 refused
Error: org.apache.http.conn.HttpHostConnectException: Connection to http://127.0.0.1:51042 refused
** Activity (main) Pause, UserClosed = true **
 
Last edited:
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
@derez: The Server (DataCollectionServer) is running on the PC and the Device (DataCollectionDevice) is also running on the PC as an emulator.
Do you think I should install the B4A (DataCollectionDevice) on a real Device?
 
Upvote 0

derez

Expert
Licensed User
Longtime User
You should find the address of the PC and give it to the device to use in its connection to the server.

look at the " local area connection" in "network and sharing center" (this is in win7, similar in other winows systems).
Untitled-1.png
Untitled-2.png
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
Hello David,

thank you very much for your help!
The IP is 192.168.178.53 and so it works with ...
B4X:
Private link As String = "http://192.168.178.53:51042"
Your help was very usefull! :)
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Hi guys,

Been away for many months

Glad to be back

Please can help me with this problem too?

B4J with "http://127.0.0.1:51042" works

But B4A with my IPv4 gets this Error Message:

"org.apache.http.conn.ConnectTimeoutException"

I opened Firewall Port TCP 51042 on my Desktop running B4J too

Any assistance is MUCH APPRECIATED
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Gracias Enrique,

Not calling 127.0.0.1

Using my IPv4 which is 192.168.x.x

Was using a VPN, but disconnected it too - not working either

Opened a Firewall TCP Port 51042 too
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
what happens if you ping the server?

B4X:
private Sub Connected As Boolean
    'Requires Phone Library
    Dim p As Phone
    Dim Response, Error As StringBuilder
    Response.Initialize
    Error.Initialize
    p.Shell("ping -c 1 192.168.1.10",Null,Response,Error)

    If Error.ToString="" Then
        Return True
    Else
        Return False
    End If
End Sub

are you receiving connection refused on b4a?
 
Upvote 0
Status
Not open for further replies.
Top