Unable to run OpenTok's WebRTC demo - php

Recently I tried to use OpenTok's WebRTC demo for a web application requiring peer-to-peer video/audio communication.
I went through the tutorials on http://www.tokbox.com/opentok/webrtc/docs/js/tutorials/ and http://www.tokbox.com/opentok/docs/server/server_side_libraries.html and I got something working using JavaScript (client-side) and PHP's library (server-side) for token/session generation.
I managed to code a basic peer-to-peer chat room locally. However, as soon as I upload it to a web server it blows up returning the following error:
Fatal error: Uncaught exception 'RequestException' with message 'Request error: Failed
to connect to 70.42.47.98: Permission denied' in /home/www/dummy_url.com/php-
sdk/SDK/Opentok-PHP-SDK/OpenTokSDK.php:192 Stack trace: #0 /home/www/dummy_url.com/php-
sdk/SDK/Opentok-PHP-SDK/OpenTokSDK.php(107): OpenTokSDK->_do_request('/session/create',
Array) #1 /home/www/dummy_url.com/php-sdk/SDK/Opentok-PHP-SDK/OpenTokSDK.php(221):
OpenTokSDK->createSession('74.96.245.119', Array) #2 /home/www/dummy_url.com/php-
sdk/index.php(16): OpenTokSDK->create_session('74.96.245.119', Array) #3 {main} thrown
in /home/www/dummy_url.com/php-sdk/SDK/Opentok-PHP-SDK/OpenTokSDK.php on line 192
I took a look at line 192:
//die(function_exists('curl_version')); // debugging
$res = curl_exec($ch);
if(curl_errno($ch)) {
throw new RequestException('Request error: ' . curl_error($ch)); // <=== LINE 192
}
curl_close($ch);
and verified the server had curl enabled. It does.
Then I tried to run the demo test and it fails at:
Assertion Failed: File '/home/www/skillfullearning.net/test/test/TestOpenTokSDK.php'
Line '102'
Code ''
What's in Line '102'? This:
...
$token = $a->generateToken("mysession", RoleConstants::MODERATOR, gmmktime() + 100000);
assert('$token');
$token = $a->generateToken("mysession", RoleConstants::MODERATOR, gmmktime());
assert('$token');
try {
$token = $a->generateToken("mysession", RoleConstants::MODERATOR, gmmktime() +
1000000);
assert(false);
} catch (Exception $e) {
assert('$e'); // <================ LINE 102
}
...
I really don't know where to go from here. I would really appreciate some help with this matter.
/E

The error is caused by outdated tests. Here is an outstanding issue, hopefully it will be resolved soon. if you simply remove the test files, you would not have that problem anymore.

Related

Gitkit_ServerException: Error code: 17

I'm attempting to implement the password reset flow for Google Identity Toolkit with the php sdk. I am able to use the sdk to do everything needed except setting up the mail endpoint which exits with the following error.
Here is the code that generates the exception:
try {
$oobResult = $gitkitClient->getOobResults();
echo $oobResult['response_body'];
}
catch (Exception $e) {
print "Exception $e";
}
And the exception:
Exception exception 'Gitkit_ServerException' with message 'Error code: 17' in C:\...\vendor\google\identity-toolkit-php-client\src\RpcHelper.php:229
Stack trace:
#0 C:\...\vendor\google\identity-toolkit-php-client\src\RpcHelper.php(208): Gitkit_RpcHelper->checkGitkitError(Array)
#1 C:\...\vendor\google\identity-toolkit-php-client\src\RpcHelper.php(179): Gitkit_RpcHelper->invokeGitkitApiWithServiceAccount('getOobConfirmat...', Array)
#2 C:\...\vendor\google\identity-toolkit-php-client\src\GitkitClient.php(371): Gitkit_RpcHelper->getOobCode(Array)
#3 C:\...\vendor\google\identity-toolkit-php-client\src\GitkitClient.php(299): Gitkit_Client->buildOobLink(Array, 'resetPassword')
#4 C:\...\auth\mail.php(14): Gitkit_Client->getOobResults(Array, '192.168.1.1')
Does anyone know what this error indicates and how to resolve it?
This function from the readme.md generates the same 'Error code: 17'
$gitkitClient->getEmailVerificationLink("emailgoeshere");
These functions from the readme.md do work as expected:
$gitkitClient->getUserById("useridgoeshere");
$gitkitClient->deleteUser("useridgoeshere");
$gitkitClient->getAllUsers(3);
This is caused by a known issue on Identity Toolkit and is now fixed. Can you go the Google Developer Console and make sure you have the correct send email endpoint in your Identity Toolkit config? Also make sure you put the same send email endpoint in your widget config. It should work now.

Couldn't resolve host '1511623453.cloud.vimeo.com'

Alright... I've chased the trail around the internet for this one, and I'm coming up with nothing.
Trying to use the PHP Vimeo API to upload videos. I have upload permission on my app, I've got tokens, and client id and secret stuff all set up, and a small myriad of other things that I've put together to make everything work... and... now I'm getting this and I have no idea what to do with it :P
PHP Fatal error: Uncaught exception 'Vimeo\Exceptions\VimeoRequestException' with message 'Unable to complete request.[Couldn't resolve host '1511623453.cloud.vimeo.com']' in /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php:154 Stack trace:
#0 /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php(396): Vimeo\Vimeo->_request('https://1511623...', Array)
#1 /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php(320): Vimeo\Vimeo->perform_upload('users/test/outp...', Array)
#2 /home/theo/software-dev/vim_test.php(20): Vimeo\Vimeo->upload('users/test/outp...', false)
#3 {main} thrown in /home/theo/software-dev/classes/vimeo/src/Vimeo/Vimeo.php on line 154
The upload script is super simple, and I doubt to be the source of the error, though here it is:
1 <?php
2 include("./config/vim.php");
3 require("./classes/vimeo/autoload.php");
4
5 $lib = new \Vimeo\Vimeo($client_id, $client_secret);
6
7 $lib->setToken($token);
8
9 $response = $lib->upload('users/test/output.mp4', false);
Any suggestions or thoughts?
Thanks!
Try and close all the browers on the computer or phone then make sure your api has the lastet version.

soundcloud api php add follower

I am making a page where you can log in with your soundcloud and gain access to download my songs as long as you are following me on soundcloud. I have authentication working but cannot figure out the following part. I pretty much copied and pasted the examples from the soundcloud developers website under the like and follow section, and it seams neither is working how its supposed to. The try catch makes it appear that i am not following my main account (which i got the user id# from testing the authentication step) even if i go on soundcloud, on my test account and follow my main account. Here is the error I am getting:
Warning: Missing argument 2 for Services_Soundcloud::put(), called in /my_website/index.php on line 43 and defined in /my_website/Services/Soundcloud.php on line 636
Notice: Undefined variable: postData in /my_website/Services/Soundcloud.php on line 642
Fatal error: Uncaught exception 'Services_Soundcloud_Invalid_Http_Response_Code_Exception' with message 'The requested URL responded with HTTP code 404.' in /my_website/Services/Soundcloud.php:941
Stack trace:
#0 /my_website/Services/Soundcloud.php(645): Services_Soundcloud->_request('https://api.sou...', Array)
#1 /my_website/index.php(43): Services_Soundcloud->put('/me/followings/...')
#2 {main}
thrown in my_website/Services/Soundcloud.php on line 941
heres the code im running:
require_once 'Services/Soundcloud.php';
//session_destroy();
session_start();
$soundcloud = new Services_Soundcloud(client_id, secret_id, redirect_uri)
$authURL = $soundcloud->getAuthorizeUrl();
echo "<pre>";
if (!empty ($_SESSION['token'])){
$soundcloud->setAccessToken($_SESSION['token']);
} else if(!empty($_GET['code'])){
try{
$accessToken = $soundcloud->accessToken($_GET['code']);
$_SESSION['token'] = $accessToken['access_token'];
$soundcloud->setAccessToken($_SESSION['token']);
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
exit($e->getMessage());
}
} else {
echo "<a href='".$authURL."'><img border='0' alt='Connect with Soundcloud' src='connect.png'></a>";
}
if (!empty ($_SESSION['token'])){
// check the status of the relationship
echo $_SESSION['token'];
try {
$soundcloud->get('/me/followings/#######');
} catch (Services_Soundcloud_Invalid_Http_Response_Code_Exception $e) {
if ($e->getHttpCode() == '404')
print "You are not following user #######\nTrying to follow now\n";
$soundcloud->put('/me/followings/#######');
}
}
Are the examples on soundcloud wrong or am i doing something wrong before i get to those commands?
also please note that my soundcloud object init and followings/##### was changed to protect my information.
after a lot of research and trial and error if figured out that setting the path to:
https://api.soundcloud.com/me/followings/#######?oauth_token=MY_TOKEN
seems to work. I don't know if this is just a workaround or how the API was intended to be used but its the only way i could get it to work, i was assuming the soundcloud client object was sending the token automatically with the command but it appears not.
I have also figured out that if it does find a match (user is following the id number) then it returns a 303 error, which the api guide does not even list in their http error codes.
You have a slash in front of me which must not be there. The following works for me:
$soundcloud->put('me/followings/#########','',array(CURLOPT_HTTPHEADER => array('Content-Type: application/xml')));

aws s3 php: fails to upload directory using UploadSyncBuilder

I am trying to upload a 14MB directory to s3 using aws php sdk. These are following scenarios and their results
Upload from my local system(india) to s3(us-east-1): success
Upload from ec2(ap-southeast-1) to s3(ap-southeast-1): success
Upload from ec2(ap-southeast-1) to s3(us-east-1): FAIL
The following code I have used
require('application/classes/vendor/autoload.php');
use Aws\S3\S3Client;
use Aws\Common\Credentials\Credentials;
use Aws\S3\Sync\UploadSyncBuilder;
use Guzzle\Log\ClosureLogAdapter;
use Guzzle\Plugin\Log\LogPlugin;
$newCredentials = new Credentials("API_KEY", "SECRET_KEY");
$s3 = S3Client::factory();
//$logPlugin = Guzzle\Plugin\Log\LogPlugin::getDebugPlugin();
$stream = fopen('out.log', 'w');
$logPlugin = new LogPlugin(new ClosureLogAdapter(function ($m) use ($stream) {
fwrite($stream, $m . PHP_EOL);
}), "# Request:\n{request}\n\n# Response:\n{response}\n\n# Errors: {curl_code} {curl_error}", true);
$s3->addSubscriber($logPlugin);
$s3->setCredentials($newCredentials);
$s3->setRegion("us-east-1");
UploadSyncBuilder::getInstance()
->setClient($s3)
->setBucket("BUCKET")
->setAcl("public-read")
->uploadFromDirectory("/mnt/1410503562Welcome to Leap!.zip_ext")
->setKeyPrefix("customs3/game10906/1410501964WelcometoLeap.zip_ext")
->setConcurrency(5)
->build()
->transfer();
Exception
PHP Fatal error: Uncaught exception 'Guzzle\Service\Exception\CommandTransferException' with message 'Errors during multi transfer (Guzzle\Http\Exception\RequestException) ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php line 569
Error completing request
#0 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(378): Guzzle\Http\Message\Request->processResponse(Array)
#1 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Message/EntityEnclosingRequest.php(49): Guzzle\Http\Message\Request->setState('complete', Array)
#2 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(286): Guzzle\Http\Message\EntityEnclosingRequest->setState('complete', Array)
#3 ./application/classes/vendor/guzzle/guzzle/src/Guzzle/Http/Curl/CurlMulti.php(244): Guzzle\Http\Curl\CurlMulti->processResponse(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Curl\CurlHandle), Array)
#4 ./application/classes/vendor/guzzle/guzzle in /vol/selfserve/application/classes/vendor/guzzle/guzzle/src/Guzzle/Service/Exception/CommandTransferException.php on line 25
I have setup log to debug and dig through Guzzle library as well. I found that when it fails, for a request no response comes. When I set concurrency to 1, it succeeds but takes much time. It fails even at concurrency of 2.
If any file fails, whole upload fails leaving it in partial uploaded state. I could not find any way to set options to retry if something fails.
Thanks for help!
After contacting with AWS support I was able to solve this with their help. Issue was in guzzle library. Following is the response from AWS support
This error occurs when cURL fails to rewind a stream and does not
associate an error with a curl handle. We've added checks to account
for this situation and automatically retry. Please ensure that they
are using the latest version of the SDK and version 3.9.2+ of Guzzle.

HttpRequest and HttpRequestPool errors and how to deal with them

I'm using HttpRequest and HttpRequestPool to send parallel http requests, the number of requests is up to 200 or something, the thing is that some of the receivers might be offline, so that HttpRequestPool::send() will wait until it gets a response or until it times out.
Example of usage:
$query = "CALL GetBoardsURLS()";
$result = mysql_query($query) or die("ERROR:QUERY_FAILED 8" . mysql_error());
$pool = new HttpRequestPool();
//Add the data to the request pool.
while($row = mysql_fetch_row($result))
{
$req = new HttpRequest($row[0].'/', HTTP_METH_POST);
$req->setBody($message);
$pool->attach($req);
}
$pool->send();
In my php error log i get errors, can someone tell me what I have to do to avoid them? I'm guessing that this happens mostly because of timed out requests to invalid destinations, becaues all receivers that are valid do get the message and act accordingly.
Any suggestions?
Ty in advance.
**ERRORS**:
[13-Nov-2012 14:20:00 UTC] PHP Fatal error: Uncaught exception HttpRequestPoolException' with message 'Exception caused by 2 inner exception(s)' in C:\inetpub\wwwroot\DeusTesting\TimeSet.php:130
inner exception 'HttpInvalidParamException' with message 'Empty or too short HTTP message: ''' in C:\inetpub\wwwroot\DeusTesting\TimeSet.php:0
inner exception 'HttpRequestException' with message 'Timeout was reached; Connection time-out (http://sim6261.agni.lindenlab.com:12046/cap/11b23456-63bd-1c56-8692-b640ac992a76/)' in C:\inetpub\wwwroot\DeusTesting\TimeSet.php:130
Stack trace:
#0 C:\inetpub\wwwroot\DeusTesting\TimeSet.php(0): HttpRequestPool->send()
#1 {main}
thrown in C:\inetpub\wwwroot\DeusTesting\TimeSet.php on line 130
[13-Nov-2012 14:30:03 UTC] PHP Fatal error: Uncaught exception 'HttpRequestPoolException' with message 'Exception caused by 12 inner exception(s)' in C:\inetpub\wwwroot\DeusTesting\TimeSet.php:130
Okay, this question was around here for a while and not answered. So I'll say what I did to get rid of the errors.
$pool = new HttpRequestPool();
//Add the data to the request pool.
foreach($boardsURLS as $boardURL)
{
$req = new HttpRequest($boardURL.'/', HTTP_METH_POST);
$req->setBody($message);
$req->setOptions(array('connecttimeout' => 3, 'timeout' => 3));
$pool->attach($req);
}
$ErrorLog = fopen('Logs/GameEnd.txt', "a+");
try
{
$pool->send();
}
catch(HttpException $ex)
{
fprintf($ErrorLog, '%s', $ex);
}
fclose($ErrorLog);
The "errors" were exceptions, and since I didn't handle them they were added in the php53_errors.log. Now by adding try and catch, the exceptions could be handled so that solved it. Now I store the exceptions(timeout exceptions) in a separate file (that's because i wanted to) someone else can handle them differently of course. So not much I can do about it.
NEXT
$req->setOptions(array('connecttimeout' => 3, 'timeout' => 3));
This is the part I like. Since I don't really care about the response, I just want my http requests to get transmited to the receivers. I put a timeout of 3 seconds. That prevents my script from keep running and waiting for the responses.
Hope this will help someone. Cheers

Categories