Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error of BROADCAST_URL #7

Closed
d33pak-s1ngh opened this issue Mar 6, 2017 · 22 comments
Closed

Error of BROADCAST_URL #7

d33pak-s1ngh opened this issue Mar 6, 2017 · 22 comments

Comments

@d33pak-s1ngh
Copy link

when i try to run command php server.php got following error the value of
BROADCAST_URL is set to a localhost ip that is 127.0.0.1 .
socket

@d33pak-s1ngh
Copy link
Author

i want to create a socket through which i can listen notification on android device whenever admin issues any notification.
i am using codeigniter for server side coding with mysql.

@kishor10d
Copy link
Owner

@d33pak-s1ngh : Actually you need to provide your real-ip-address, which is generated by your lan network. e.g. 192.168.0.234

Please check with command "ifconfig" and replace ip-address with that one. It will work.

@d33pak-s1ngh
Copy link
Author

d33pak-s1ngh commented Mar 6, 2017 via email

@kishor10d
Copy link
Owner

@d33pak-s1ngh : please upload the screenshot. We will look into it together.

@kishor10d kishor10d reopened this Mar 6, 2017
@d33pak-s1ngh
Copy link
Author

ok i tried in windows 7 without changing value of BROADCAST_URL it is on its default 192.168.0.6 and i enter a value in textbox and value is getting stored in to database without any page refresh so this what websocket do??

this can be done with ajax also

what i want to do is that whenever any record insert into database i should get notifcation in android app that record has been inserted. can we do that with this websocket plugin which you have provided.

@d33pak-s1ngh
Copy link
Author

the real purpose of using websocket is that we can consume server side events and actions at client side without any page refresh. client can be android or ios app or even a web app itself.
so if an admin will generate any notification from web app an android device listening to websocket should receive a notifcation without any action performed.

thank you for any kind of help.

@kishor10d
Copy link
Owner

kishor10d commented Mar 7, 2017

@d33pak-s1ngh : I think you didn't read README.md. It is doing the same thing what are you thinking about. It is doing without page-refresh. It is just the matter of setting it up properly. I think you didn't started websocket server.

@d33pak-s1ngh
Copy link
Author

how do i start a websocket server?
i tried to run command
php server.php which throws following error

@d33pak-s1ngh
Copy link
Author

d33pak-s1ngh commented Mar 7, 2017

following is the setting in constant.php it contains my ip address and i change port from 2000 to 8181 just for testing but still getting error.
/** WEBSOCKETS BROADCAST TYPES **/

define("POST", "post");
define("BROADCAST_URL", "116.72.11.241");
define("BROADCAST_PORT", "8181");

Following is screenshot of error saying that address is already in use.

sock1

@kishor10d
Copy link
Owner

@d33pak-s1ngh : Remember, this code will not work on shared hosting server (known issue). Also if you wanna test it on localhost then you must give the ip-address of your machine over LAN (i.e. 192.168.1.xxx like that).

@d33pak-s1ngh
Copy link
Author

ok so i will host it on server and use that ip to test.

@d33pak-s1ngh
Copy link
Author

will do it sure i want to understand socket

@d33pak-s1ngh
Copy link
Author

hii @kishor10d i think everything working fine except that connection.js is not able to make connection with socket server check the following from firefox browser.
socket

all this is happening because php server.php command is not executing the script successfully it throws error of BROADCAST_URL error.

you are saying that i have to provide lan ip as value of BROADCAST_URL that is also fine.

but i have 2 machines connect with same lan ip and you are saying that it will not work with share hosting server so what should i do?
how i can set an ip?
please help me to understand.
thank you.

@kishor10d
Copy link
Owner

@d33pak-s1ngh : You need to keep the websocket server running. That warning means your socket is not running. Also instead of ip_address you can give your domain name also. (e.g. example.com). If you have root access then you can make it run on your shared hosting too.

Websocket server cannot be keep running, so you have to ping it after some interval. You can schedule a cron job (dirty practice) or refer this http://stackoverflow.com/questions/19487664/how-do-i-keep-a-websocket-server-running-even-after-i-close-the-ssh-terminal

@d33pak-s1ngh
Copy link
Author

i dont have a domain name i have an ip address of my server and i have a root access of that server
i have hosted your application on that and i am accessing it from server like
104.131.2.03/socket

@d33pak-s1ngh
Copy link
Author

whenever i type command php server.php it doesnt give any result then i have to interrupt the service and again fire the command than it gives error that address is already in use.

@kishor10d
Copy link
Owner

kishor10d commented Mar 11, 2017

@d33pak-s1ngh : It doesn't give any result means it is working. Don't interupt it. and try from your browser.

@d33pak-s1ngh
Copy link
Author

finally found the problem and now it is working fine. i open in two tabs and enter some value from one tab which is now appear's in both tab.

the problem was after typing command php server.php there was no result so i press ctl+z to stop it then again i try php server.php then it throws error that address is in use because in previous command it started websocket server but after typing it again mess the port.

@d33pak-s1ngh
Copy link
Author

thanx kishor i got it but now the problem is i cant keep my cmd open all time . this thing should be running in background all the time. what should i do for it??

@d33pak-s1ngh
Copy link
Author

also i checked your admin panel in codeigniter in codeinsect how i can add this socket feature in to that codeigniter panel?

@kishor10d
Copy link
Owner

kishor10d commented Mar 11, 2017

Here is the solution for your command line problem. Also you can free your ports by killing the process. Everything explain in the following url.
Please refere this url :
http://stackoverflow.com/questions/19487664/how-do-i-keep-a-websocket-server-running-even-after-i-close-the-ssh-terminal

And you ask about CodeInsect Admin Panel, actually it is ready admin panel and you can add your features into it. Its your choice that how you integrate your code into it. Just copy and paste the same things of third_party folder, and implement the controllers into controllers. You can do it easily.

@d33pak-s1ngh
Copy link
Author

ook thank you for this awesome work i will try to merge admin panel with socket and inform u.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants