This is the tutorial I used:
http://www.flynsarmy.com/2012/02/php-websocket-chat-application-2-0/comment-page-1/#comments
Basically I downloaded the source code, placed the files in a folder: http://mmhudson.com/ws
server.php:
http://mmhudson.com/ws/server.php
I simply can't get it to connect. I tried running server.php from both the command line and the browser and both times it wouldn't connect. The ws folder has all the files in the downloadable source included.
Any ideas of what I can try?
I think I found the solution. You are opening a connection to localhost/127.0.0.1. As soon as you put the code on a server, you'll have to specify the server URL instead of localhost/127.0.0.1 for the client. I tested the server.php and it is working fine, only the client doesn't connect to it.
Try this for index.html
Server = new FancyWebSocket('ws://mmhudson.com:9300');
Related
I want to connect to a remote (AWS) mysql server using ssl in PHP.
My script works when I execute it via command line, but doesn't when I call it from the browser.
$con=mysqli_init();
mysqli_ssl_set($con,NULL,NULL,"path/to/cacert.pem",NULL,NULL);
$link = mysqli_real_connect($con, "host", "username", "password");
I am using php7/Apache/CentOs. I tried changing the ownership and permissions of the CA file, and noticed that it requires read permission the be executed on console. But in browser even if I give full permission to everybody (chmod 777) it still doesn't work.
The error i get is:
Warning: failed loading cafile stream.
When I check existence of file it returns true, but when I check is_readible, then also error.
Can somebody help?Thanks!
So as I figured there was (is) something wrong with readability and maybe permissions. I could narrow down the problem to the certificate file being existent but not readable. I moved it to my server with filezilla via ftp.
I could solve my problem by creating a new .pem file and simply copying the content of my original file into it. This one is readable now and works in browser, but I can't figure out why as they both have the same chmod xxx permissions and chown ownership.
Detailed description(for users with similar problem using AWS MYSQL):
open rds-combined-ca-bundle.pem file(download link: https://s3.amazonaws.com/rds-downloads/rds-combined-ca-bundle.pem) in text editor.
Copy content.
On your server, where php script should run create new file and paste text into it.(it might require some additional editing, begin/end tags in separate line and new lines end at the same place as in original text)
I had created this CMS system which uses a mySQL database and creates a file on the server.
The database side works as intended, but the creation of the file not so well.
Everything works perfectly on my localhost but the creation of the file is not working right on the external WWW server.
I had created a basic script to test the functionality of fopen() on the server. That had worked correctly, but for the real script it doesn't work.
This is the code in the real script:
if(fopen(strtolower("../News/" . $titleURL . ".php"), "w+")){
$createdPage = fopen(strtolower("../News/" . $titleURL . ".php"), "w+");
echo "page created";
}else{
echo "creation failed";
}
When this page is run, I get creation failed.
This code runs fine on the localhost, but why not on the external site?
EDIT:
My hosting service does not block fopen()
IT is very likely that the configuration for your host server (and/or the target server) does not allow any file manipulation on/by a foreign server.
Problem is resolved. I had just cleaned up the code a bit, cleaning up a lot of concatenating URLs. It appears the server did not appreciate me concatenating file locations. Everything is working fine.
I have built Catcoind (a fork of the Bitcoin / project) and I can access the commands in my terminal by doing this from root:
cd catcoin/src
./catcoind -daemon
That will start Catcoind, open the port, and allow me to type commands like './catcoind getdifficulty', but I want to access them from a PHP JSON-RPC client running on another server. The code I currently have there is:
<?php
require_once 'jsonRPCClient.php';
$catcoin = new jsonRPCClient('http://RPCUSER:RPCPASS#IP:PORT');
print_r($catcoin->getinfo());
echo $catcoin->getdifficulty();
My config file for the Catcoind build on Ubuntu is:
server=1
rpcuser=USER
rpcpassword=PASS
rpcssl=0
rpcallowip=*
bind=IP:PORT
externalip=IP
proxy=IP:PORT
port=PORT
rpcconnect=IP
When I run the code, it says that it failed to open the stream / connection refused. The config for Catcoind is at location ~/.catcoin/catcoin.conf. Any ideas? I know this is confusing, but I have really everything done but allowing external IPs to access the API. Thanks! :D
You don't need all these things to be written in conf file just use following
server=1
daemon=1
rpcuser=<user_namer>
rpcpassword=<password>
rpctimeout=30
if connecting from remote host do add following line
rpcallowip=<remote_ip_address>
save and exit from conf file and restart daemon by first stopping it catecoind stop and then catcoind start
Are external IP allowed? If not make sure that the IP is allowed so that it can call the api. The error failed to open the stream / connection refused usually means that the ip and everything is correct but the server rejected the connection.
I've done some research on an issue I'm having with taking a remote directory from Server A and linking that directory to Server B. I'm not fully sure if I can take the remote directory using PHP and use the contents from that directory on Server B
Here's what is what I want to go one between both servers
Server A (code.php)
<?php
$FileTitle = '/code/';
if (!isset($_GET['file'])) {
exit('This file cannot be found');
}
$FileTitle = $_GET['file'];
?>
What I have going on with this script is that every time a person enters in a url ending with /code.php?=testfile.txt or any other file in the directory /code/ on Server A will be echoed using <?php echo $FileTitle; ?>. My problem with this is that I host all the files on Server A rather on Server B. I want the title of the file from the URL to show up in index.php on Server B
Server B (index.php)
<?php
include 'http://example.com/code.php';
?>
<?php echo $FileTitle; ?>
I'm planning for this to take the code from Server A and be able to find the directory /code/ on that server as well.
I've done a ton a research the past few days both on Stackoverflow and around the internet. I haven't found anything even close to what I am trying to do. If you can, please show me how to do this. I would really appreciate figuring out how to have a remote connection to a file on another server and be able to use that file remotely. Thanks :)
code.php will execute on the remote server so you will get the output of code.php if any. The only thing I can think of is writing a script that outputs code.php..
Ex:
server b, index.php
<?php
eval(str_replace(array('<?php', '?>'), '', file_get_contents('http://example.com/sendcode.php)));
?>
server a, sendcode.php
<?php
$code = file_get_contents('code.php');
echo $code;
?>
Completely insecure, but it works.
Edited: try new server b code. If that doesn't work I'm out of ideas.
I have a script that uses ftp_connect() among other FTP PHP functions for uploading a file.
ftp_connect() works when executed on my local development server for connecting to a remote FTP server. The same script, when executed on the remote server does not work for connecting to the exact same FTP server.
Could somebody please point me in the right direction?
Thanks!
Here is the code:
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$server = 'ftp.someserver.com';
$ftpConn = ftp_connect($server);
if(!$ftpConn)
echo 'failed';
else
echo 'success';
No errors are reported.
So if I understand it correctly then the script above is installed on the server that you're trying to access using FTP (ie. the script is opening a local FTP connection)? What's the use? FTP in PHP is only useful to transfer files between 2 servers, you cannot use it to transfer files from the client to the server (since the script is executed on the server).
edit
Something I didn't add in my original comment : you could use a Java FTP applet if you want to transfer files from the client to the server. But be aware of the security issues involved (because the user credentials can be sniffed :p).
Probably firewall issues. On top of that, FTP was not designed with NAT in mind.
Try to login to the production server and use a ftp client to do the same connection.
I do not know the things inside it very well but I want to give my little help.My server is ubuntu Linux with Apache、PHP and MySQL,and my develop env is MAMP on Mac.
I met the problem suddenly and cannot find what happened because it was worked yesterday,I searched many answers and can't solved it.The ftp_connect($ftp_server) only return bool(false),but I can use my FileZilla,interesting,is it?
So I try to connect the server from my command line,like ftp 111.22.333.44,It shows:
500 OOPS: cannot read user list file:/etc/vsftpd/vsftpd.user_list
I login in my ubuntu server, and didn't find the vsftpd directory,and the vsftpd.user_listis in the directory /etc/,still don't know what happened.
So I simply create the directory and copy the file vsftpd.user_list to it.Then I try ftp 111.22.333.44(your IP address) again and it works now.
hope it help someone else.