b4aserver won't connect

derez

Expert
Licensed User
Longtime User
Hi
I run the b4a server example http://www.b4x.com/forum/additional...l-updates/9679-b4aserver-files.html#post53630 from my device (which runs in a local network) as is and it does not connect to the server.
I made the modifications to the desktop php file, changed URL line to be:
BoardUrl=http://192.168.0.104/b4a_server.php
(this is my desktop's ip)
I run the batch file - it runs and does not finish running (keeps blinking).
In the device program I changed to
B4X:
B4AServer.Initialize("http://192.168.0.104/b4a_server.php", ServerName, "Main")
I run it with and without bridge connection and the server does not connect when clicking any of the buttons.
The message is always success=false, and the reason - task cancelled.

I tried both win7 and xp desktops.

the log:
** Service (b4aserverservice) Start **
Server not connected. Calling board web service.
Error connecting: org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.0.104:80 timed out
Connected = false
Task=1 completed. Success=false, Message=Task cancelled

Help ?
 
Last edited:

derez

Expert
Licensed User
Longtime User
I don't know!
I changed the config file and run the batch from the link above.

What else should be done?

Edit:
I tried to access the server from a browser - put as URL the ip/b4a_server, got request for username and password !
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
I've read this tutorial, loaded the files from the files link and try to run the server and do the simple tasks (dir, loadfile etc.) from a device on the same local net as the desktop, using the local IP of the desktop for the URL.
I understand the board is not required if I don't intend to use a sql table.
So why it doesn't connect ?

Edit: I see in the server file that it has the four lines of the sql at the top. Should I delete them ?
Edit: Deleted them but the connection is still refused because there is no authentication.
how do I send the username and password to the router from the device's application ? Why is it required when I work inside the lan ?

log:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (b4aserverservice) Create **
** Service (b4aserverservice) Start **
Server not connected. Calling board web service.
Error connecting: Unauthorized
<html>

<head><title>401 Unauthorized</title></head>

<body><h1>401 Unauthorized</h1>

<p>Access to this resource is denied, your client has not supplied the correct authentication.</p></body>

</html>

Connected = false
Task=1 completed. Success=false, Message=Task cancelled


Edit: that last log was recieved when trying to connect at my son's home, the password required is the router's password for management of the net - nothing to do with the server.
At home I don't get this request but the server doesn't connect either.
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
There is a third component which is a PHP server. You can use the default one during development.

Which is the default board server ? How do I install it ?
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User

I'm taking a guess here:


BoardUrl=http://xx.xx.xx.xx/b4a_server.php


This has to point to an ip address somewhere
with a webserver running on it.

so this could mean two things,
a a windows based web server?
(or a unix machine/server with apache on it)

Run ASP on Your Computer

install a web server on your local windows machine (and php too)
then it would be

BoardUrl=http://192.168.0.5/b4a_server.php

or what ever the ip of your windows machine is
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
Thanks for trying to help, vb1992.

As I wrote above, the internal (lan) ip is 192.168.0.106 and I don't need an external web server, only to serve the devices within my home network.

I tried the asp but my comuter refuses to install IIS, so I can't even check this.

I really give up on this. I was just trying to learn it but the short help responses didn't advance me anywhere, and also I don't actually need it for any application.
Thanks again.
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
Few steps forward:
I managed to install a board server (xampp) and it works in the local net on port 80. I put a ""hello.php" file in the docs folder and I can see it by browsing from devices to "http://192.168.0.106/hello.php"

The example in the b4aserver files work also, and with slight modification I can recieve two files from the desktop and store them in a sub directory in the SDcard.

When I change the address from the basic4ppc to my desktop IP in both the config file and the b4a device program:
B4X:
"http://192.168.0.106/b4a_server.php"
- the connection fails.
-If I put the desktop files in the board server docs directory ( like the hello.php file) and run it from there, the run.bat provides a long list of massages refering to the IP (see attached). the IP 111.222.111.222 is of a company in china !
http://www.plotip.com/ip/111.222.111.222
- I get the following log:
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (b4aserverservice) Create **
** Service (b4aserverservice) Start **
Server not connected. Calling board web service.
** Service (b4aserverservice) Start **
Error connecting: Not Found
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>

<title>Object not found!</title>

<link rev="made" href="mailto:postmaster@localhost" />

<style type="text/css"><!--/*--><![CDATA[/*><!--*/ 

    body { color: #000000; background-color: #FFFFFF; }

    a:link { color: #0000CC; }

    p, address {margin-left: 3em;}

    span {font-size: smaller;}

/*]]>*/--></style>

</head>

<body>

<h1>Object not found!</h1>

<p>
    The requested URL was not found on this server.
    If you entered the URL manually please check your
    spelling and try again.
</p>
<p>
If you think this is a server error, please contact
the <a href="mailto:postmaster@localhost">webmaster</a>.
</p>
<h2>Error 404</h2>
<address>
  <a href="/">192.168.0.106</a><br />
  <span>Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7</span>
</address>
</body>
</html>
Connected = false
Task=1 completed. Success=false, Message=Task cancelled
Task=2 completed. Success=false, Message=Task cancelled

What am I doing wrong ?
 
Last edited:
Upvote 0

derez

Expert
Licensed User
Longtime User
I managed to install a board server (xampp) and it works in the local net on port 80. I put a ""hello.php" file in the docs folder and I can see it by browsing from devices to "http://192.168.0.106/hello.php"

I see it by browsing from a device !
Any specific configuration that I need ?
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Erel
The b4a_server.php file is found by the server, in the c:\xampp\htdocs folder. If the file is not there the error list does not appear at all.
The problems are due to something in that file that the server doesn't like.
 
Upvote 0

derez

Expert
Licensed User
Longtime User
Browsing to http://192.168.0.106/b4a_server.php from a device display the content of this file:
B4X:
UNIX_TIMESTAMP(now()) - 60;", mysql_real_escape_string($server)); $result = mysql_query($query); if (!$result) die('Invalid query: ' . mysql_error() . ' ' . $query); if (mysql_num_rows($result) > 0) { mysql_query("LOCK TABLES b4a WRITE;"); $result = mysql_query($query); header("Content-Length: ".mysql_num_rows($result)); while ($row = mysql_fetch_assoc($result)) { echo $row['ip']; echo "\n"; } $result = mysql_query(sprintf("DELETE FROM b4a WHERE server = '%s';", mysql_real_escape_string($server))); if (!$result) die('Invalid query: ' . mysql_error() . ' ' . $query); $result = mysql_query("DELETE FROM b4a WHERE time < UNIX_TIMESTAMP(now()) - 60;"); if (!$result) die('Invalid query: ' . mysql_error() . ' ' . $query); mysql_query("UNLOCK TABLES;"); } } else { echo "missing parameters."; } ?>
 
Upvote 0
Top