How to check status of Peerjs? - peerjs

Instead of keep tracking all the status change. What I am doing is, so far seems working fine. Can someone please verify?
ICE Status
peer && peer.id && !peer.disconnected && !peer.destroyed
Data Connection Status
peer && peer.dataChannel && peer.dataChannel.readyState === "open"
Streaming Status
What is the best way? I can't figure this out.

Related

Is there a way of checking if an action has been successfully completed in ThingSpeak?

I am trying to read data in ThingSpeak, but I would like to have some conditional statement that says if the data was not read successfully, then a certain error message should display. Is there a way to check if a specific Read action was successful, so that I can do this?
Yes, there is a built-in operation with the ThingSpeak Arduino Library: ThingSpeak.getLastReadStatus()
Here's some code to get the last status and test it:
// Check the status of the read operation to see if it was successful
statusCode = ThingSpeak.getLastReadStatus();
if(statusCode == 200){
Serial.println("Counter: " + String(count));
}
else{
Serial.println("Problem reading channel. HTTP error code " + String(statusCode));
}

Getting error while accessing rally using rally-rest-api-2.1.2.jar

I am getting an authentication error for API key in rally. Even api key is given full access.
java.io.IOException: HTTP/1.1 401 Full authentication is required to access this resource
at com.rallydev.rest.client.HttpClient.executeRequest(HttpClient.java:163)
at com.rallydev.rest.client.HttpClient.doRequest(HttpClient.java:145)
at com.rallydev.rest.client.ApiKeyClient.doRequest(ApiKeyClient.java:37)
at com.rallydev.rest.client.HttpClient.doGet(HttpClient.java:221)
at com.rallydev.rest.RallyRestApi.query(RallyRestApi.java:168)
This is The code :
String wsapiVersion = "v2.0";
restApi.setWsapiVersion(wsapiVersion);
restApi.setApplicationName(projectname);
QueryRequest testCaseRequest = new QueryRequest("Testsets");
if(null !=workspace && ""!=workspace)
testCaseRequest.setWorkspace(workspace);
QueryResponse testCaseQueryResponse = restApi.query(testCaseRequest);
What is wrong here ?
One of the things I would check for is whether you are inside a corporate network that uses authenticated proxy servers. Unless you configure the connection correctly, the proxy will reject your request before it even gets to Rally.
Second thing I just thought of is, whether you are setting the right field in the header to enable the use of an APIKey. The Rally servers expect the ZSESSIONID to be set to the APIKey, I believe.

SailsJS CSRF mismatch error customize

I need to customise the error that shows up when someone did not send the CSRF code with the POST request.
So that no one will know what happened with the error and they will not even try to hack in to the CSRF mechanism.
Hope this is clear
For now Sails.js CSRF hook uses res.forbidden() function to handle wrong CSRF token.
It uses it with this message:
return res.forbidden("CSRF mismatch");
So you could rewrite this response by placing a new file with name forbidden.js into /api/responses
Actually you cound copy this one: https://github.com/balderdashy/sails/blob/master/lib/hooks/responses/defaults/forbidden.js
And add condition to check data before production mode check:
...
else sails.log.verbose('Sending 403 ("Forbidden") response');
if (data == 'CSRF mismatch') {
//Return another response for example:
return res.jsonx(500, {/* data here */});
}
// Only include errors in response if application environment
// is not set to 'production'. In production, we shouldn't
// send back any identifying information about errors.
if (sails.config.environment === 'production') {
...
Anyway as long as you will use development mode for sails. You will see all errors when getting 500 or any other error from sails. But in production mode all error messages will be hidden. And your users wouldn't get any error details. Except of error code.
So in production mode without any changes you will get only HTTP 403 code.

Is it possible to disconnect a client mid-request?

I'm trying to simulate the situation where a client is sending a large POST request to the server and the server (or a load balancer) terminates the client connection halfway through the request.
Is this possible to do with Fiddler? I'm open to other (Windows) tool suggestions as well.
Thanks!
Click Rules > Customize Rules. Scroll to the OnPeekAtRequestHeaders function. Add code like so:
static function OnPeekAtRequestHeaders(oSession: Session) {
if (oSession.uriContains("myupload.php") &&
oSession.oRequest.headers.Exists("Content-Length") &&
oSession.oRequest.headers["Content-Length"] != "0")
{
oSession.oRequest.pipeClient.EndWithRST();
}
}

Kohana module restify URL

Hi I am trying to work with this module ->
http://kohana-modules.com/modules/michealmorgan/kohana-restify
It works great except when I use curl to send requests, if I send this
localhost/restify/test?id=1
then I get the value of id
If I do this
localhost/restify/test/1 or
localhost/restify/test/index/1 I get routed to the defualt page (error page)
So I asume Index is mapped to GET ,so anything thats not test/index is routed, but I cant figure out how to allow it to accept it.
Has anyone solved this ?
thanks
if (trim(Request::detect_uri(), '/') == 'restify/test')
{
Route::set('restify/test', '<directory>(/<controller>(/<action>(id/<id>)))')
->defaults(array
(
'directory' => 'restify',
'controller' => 'test'
try inserting this in your bootstrap...
echo Debug::vars(trim(Request::detect_uri(), '/'));
if it does not equal restify/test when you curl the request, something is up and you might need to fix the module