B4J Question B4X Push server - curl cannot run from php

Shay

Well-Known Member
Licensed User
Longtime User
I adjusted the push server code
if I send from command line (linux) the following:
curl --request GET 'http://localhost:51044/send?password=11116&text="message to send"'
it is working fine (the b4x server is responding)

but if I do the same from php code, it is not getting anything (server log is blank)
any idea why?
Can I add more logs to understand what happening?

on this script I am getting "0" (need to get 200 (for 200 ok)), while other pages on my apache is giving 200
B4X:
<?php


$dom_u = ""; //username
$dom_p = ""; //password
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 131072);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:51044/send?password=113306&text=%22message%20to%20send%22");
curl_setopt($ch, CURLOPT_USERPWD,$dom_u.":".$dom_p);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($info["http_code"]);
curl_close($ch);
?>
 

Shay

Well-Known Member
Licensed User
Longtime User
since the server will handle it not the user
I am doing the same with the android
Can you try the php code, ad curl and see why it is not working with php?
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I tried several ways to send http request (not just curl) none of them is working
b4x is not getting anything
if I do telnet IP:51044 from inside or outside the server, the port is responding, so this is not firewall issue

I did manage to make it to work if I put b4x on port 80, but I cannot bind it to port 80, since my apache is on this port, any idea why this is happening?
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I manage to solve this
basically I did many things so I am not sure this is the only change
if someone have this issue and the below is not solving, let me know

so I moved the default b4x port to port 81, and restart apache
(but again this might be part of the solution)
 
Upvote 0
Top