Web socket codeignetor - php

I am trying a simple chat application using websocket. For that i have taken the coding from https://github.com/kishor10d/CodeIgniter-Ratchet-Websocket.
But i have found the below issue:
Source map error: request failed with status 404
Resource URL: http://localhost/ratchat/assets/js/angular.min.js
Source Map URL: angular.min.js.map[Learn More]
Source map error: request failed with status 404
Resource URL: http://localhost/ratchat/assets/js/angular-route.min.js
Source Map URL: angular-route.min.js.map[Learn More]
Firefox can’t establish a connection to the server at ws://192.0.53.1:8000/.(192.0.53.1:8000/.:this is my IP).
i had tried on terminal by giving :
php -q /var/www/html/chat/application/third_party/Realtime/bin/server.php
but not working
Any help

First run the server.php on Your console .Then it will works. I had try it anf works fine for me

Related

Laravel based REST API: Getting images

First of all, sorry if this question is answered anywhere else, but I could not find the answer I needed so I'll ask again.
I am using laravel to create a REST API which I serve through Docker. Therefore I can reach the API through http://localhost:8888. For example, I have an endpoint /content/fetch/{env_type} which works fine through http://localhost:8888/api/content/fetch/test.
My problem is that I have some images in the (from Laravel root dir) directive /public/images/content/test. I was under the assumption that I would be able to reach these images in my frontend app using <img src="http://localhost:8888/images/content/test/myimage.jpg" /> but this does not work.
I have tried adding public/ before images/... but that did not work either. I also tried the URL to the image in the browser directly, and got 500 Internal Server Error:
Request URL: http://localhost:8888/images/content/test/myimage.jpg
Request Method: GET
Status Code: 500 Internal Server Error
Remote Address: 127.0.0.1:8888
Referrer Policy: no-referrer-when-downgrade
Looking in the laravel log I get this: production.ERROR: Uncaught ErrorException: file_put_contents(/var/www/storage/framework/views/ba2564046cc89e436fb993df6f661f314e4d2efb.php): failed to open stream: Permission denied in /var/www/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:122
I know what it means but it feels strange that I should have to change the permissions for basically the entire vendor folder.
So my guess is that I am approaching this wrong. Does anyone have an idea how I should do this instead?

I get a Failed to load resource: net::ERR_CONNECTION_REFUSED when running ionic app

I am using WAMP to to establish my pc as a server. I have some values in a database and now I want my ionic app to retrieve the data. In my app.js, I am using a get request to fetch whatever my php file gets from the db:
.controller('customersCtrl', function($scope, $http) {
$http.get("http://localhost//TempSensorTest/query.php")
.success(function (response) {$scope.names = response.records;});
When I open this url in the browser, I get a json object with the values.
However, when i run the app on my android phone the console prints:
Failed to load resource: net::ERR_CONNECTION_REFUSED http://localhost//TempSensorTest/query.php
Note that around 3 months ago I used the same method for a different app and it did work. However I do not know what might be casung this now?
In second line you have "http:http://localhost//TempSensorTest/query.php"
try to remove first "http:".

jQuery AJAX simple PHP Post not working

I've got a very basic one today! I'm trying to post from jQuery to a PHP file hosted on localhost.
My JS:
$("#searchNameButton").click(function() {
var name = $("#searchNameText").val();
$.ajax({
type: 'POST',
url: 'localhost:8080/getNameInfo.php', // -> this works fine from the browser
// data: { name: name }, -> commented out
success: function(){
alert('request successful');
},
error: function(xhr, textStatus, errorThrown){
alert('request failed');
}
})
});
My PHP file (getNameInfo.php), a very basic one for testing:
<?php
echo 'TEST';
?>
In jQuery, it will always bring me to error, saying 'Internal Server Error'.
I am using Ripple Emulator and this is what appears in the console:
POST https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=localhost%3A8080/getNameInfo.php
500 (Internal Server Error)
I assume it has to do more with this than with what's written in the files. Any advice? Thanks!
EDIT: Found this: LINK but it won't fix my issue. If I do what it says here, I won't get any error thrown ("" instead) but will still fail.
EDIT 2: If I set Cross-Domain Proxy to Local in Ripple (that's suggested in the link above) I get
OPTIONS http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//localhost%3A8080/getNameInfo.php net::ERR_CONNECTION_REFUSED
EDIT 3: Changed my URL to local
C://Mobile//Cross-Platform//TestApp//www//php//getNameInfo.php
and it's working now. Have no idea how to make it work on localhost. BUt will go with this now, as it's only a learning app.
Add a header access control at top of getNameInfo.php file :
header('Access-Control-Allow-Origin: *');
So, finally I found a solution.
Even though it's not a recommended one, running Chrome with
--disable-web-security
will allow me to call a PHP script hosted on localhost:8080 from localhost:3000 where PhoneGap / Ripple Emulator stays.

Am i using the API V2 or V3 in this piece of code?

My live, staging and localhost had a page where it had a map and store finder.
6 months down the line this now does not work and havent touched the code. I have renewed my API key and still no luck. Now i know the API V2 is now not in use and im wondering if i am using the wrong code (confused myself). In my store finder i have this url:
$url = "http://maps.google.co.uk/maps/geo?q=".urlencode($this->input->post('postcode'))."&output=json&key=MYKEY";
Now reading this page ( https://developers.google.com/maps/documentation/geocoding/#JSON ) this has changed but i just cant seem to get a valid url working!
The error i get is: Message: file_get_contents(http://maps.google.co.uk/maps/geo?q=sr3+4as&output=json&key=MYKEY): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
And when i type the url string into google i get this message:
We're sorry...
... but your computer or network may be sending automated queries. To protect our users, we can't process your request right now.
If someone can guide me to if my url string is wrong above OR if this is another issue i would appreciate it.
Thanks!
According to the upgrade guide this endpoint URL:
http://maps.google.co.uk/maps/geo
Is using the v2 geocoding API.
Developers switching from v2 may be using a legacy hostname — either maps.google.com, or maps-api-ssl.google.com if
using SSL. You should migrate to the new hostname: maps.googleapis.com.
This URL based on the information in the update guide works for me:
http://maps.googleapis.com/maps/api/geocode/json?address=nebraska&sensor=false

jQuery load() working on localhost but not on server

I have encountered a very strange problem in using jQuery load(). I used it to load a php file in a div container. It's working fine on my localhost but on the server it does not load the php file and instead gives
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I don't know why is this happening. My jQuery code is:
//ADD THE Description TO THE HOLDER
infofield.append('<div id="'+opt.style+' description" class="'+opt.style+' description">'+item.data('desc')+'</div>');
// ATTACHED the comments to the LIGHTBOX
$('.description').load('gallery_comments.php?id='+id+'&pic='+imgsrc+'&a'+ab);
Is there a server issue? Using on localhost with WAMP server and testing cross browser compatibility it runs in all browsers, even in IE8. Can any one help?
update ** just used chrome and found out one bug in Uncaught ReferenceError: $ is not defined in line 9 and line 9 code is
$(function() {
$('div.viewgp').hide();
$('.slidegp').click(function() {
$('.viewgp').fadeToggle(200);
});
});
You say you can access gallery_comments.php directly, but with what query string parameters? Are you sure that you use the same ones which are appended via the values of id, imgsrc, and ab in the following line?
$('.description').load('gallery_comments.php?id='+id+'&pic='+imgsrc+'&a'+ab);
Try the following changes to determine exactly what you're trying to load, and navigate directly to the url that comes to your console or alert box:
var url = 'gallery_comments.php?id='+id+'&pic='+imgsrc+'&a'+ab;
console.log(url); // or alert(url);
$('.description').load(url);
If I wanted to play psychic debugging, these would be my first two guesses:
one of the parameters is required server side, but is null / empty / undefined in your javascript
There is an attempt to access a resource that is accessible on your localhost environment but not on the remote server environment

Categories