Pinterest API - Timeout - javascript

Has anyone experienced the "Trying to login before initializing." error?
It seems like there is a limit to the number of calls you can make to the API but I have not hit the 1000 per hour by any means.
This even occurs after I authenticate once. Once I refresh the page, I get the message above. I end up waiting a little bit (usually a few mins) then I can authenticate again.
I would like this to go away or at least save the authentication within a cookie or something like that.
Can anyone lead me in the right direction?
Appreciate the help in advance.

I was getting that same error message when setting appId to null or undefined in PDK.init. Maybe you are doing the init logic before the actual value is assigned.
I'd recommend using environment variables to keep the App ID outside of your code and inject it at build time, similar to how Create React App does it: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables

Related

Getting a route script to run a function from another script. What am I getting wrong?

I'm trying to build a mock-up website with a register and login function. Right now I have a register page route script that should run a function (a sql query) from my database script once it receives a post request. For some reason, the function isn't running.
Since I'm not too familiar with NodeJS and SQLite it feels like the problem could be anywhere. It would be great if someone knowledgeable could point in me the right direction:
Doing some testing, I've figured that I'm not ever really reaching the dbcontroller script. Thus why I think there something wrong with my function exporting. But it might be some quirk with NodeJS. I'd love to get any help on it.
edit - I should add that I'm not really getting any error message other than my client being routed to the error page and a error 500 in the console:
POST /register 500 21.775 ms - 4447

React JS web app shows "undefined" pop up Error message when the page is not in use for few minutes or if there is no internet connection

I have an issue and i don't even know where should I start the investigation.
I have a website that based on Flask and react, i fetch stock prices from my backend every minute and it seems like when the webpage is not able to fetch the stock prices from the backend, i'm getting the attached popup message and the page got stuck.
I need to close the webpage in order to start use it again.
Can you please give me some direction, what can be the root cause?.
Error message
Thank you very much.
Try to find in the project all lines of code that execute alert(. You'll be able to find the place of a code that executes alert if there is some backend's issue.

Setting timeout for vertx-eventbus.js

I'm currently working on a Vertx based application that is making use of vertx-eventbus.js as described here: http://vertx.io/docs/vertx-web/java/#_sockjs_event_bus_bridge
So the client side is using vertx-eventbus.js to send a message to server side which has SockJSHandler doing the 'bridge' to receive the message. The whole mechanism has been working fine for few months. Only very recently we now potentially need to have higher timeout limit for certain messages. If run right now, those messages always cause the following warning on the server side (and also caused the eventbus to attempt to return too early on client side with "undefined"):
Message reply handler timed out as no reply was received - it will be removed
My question is then how do you increase the timeout for the message sending in this scenario? It seems to be using the default 30 seconds timeout and I have looked everywhere (online searches Google, here at Stackoverflow, etc) with no luck. I know there is a way to set timeout when you are sending using Vertx on the backend but not when sending from vertx-eventbus.js.
Any input is very much appreciated. Let me know if there is anything else you need to better understand what I'm trying to achieve.
Thank you,
Tom

Notifications in javascript without user input

I've been trying to figure out a way to use notifications on a background process and couldnt find anything online about it. So, I figured out one way around it and wanted to share (Not sure if this is the best way to go about doing this but here goes:)
Problem: I want to notify the user of new info when the page is running but in the background (blurred). I could use alert('new info!'); to get the taskbar icon to flash, but then you have to manually dismiss it (tried it and it's hella annoying). I really liked the notifications, but they only work if the user performs an action, so not helpful...
I hope I won't be telling something stupid, but from where I see it (and remember from school) that's basically how http works : a request is sent to the server, which issues a response eventually after executing some server-side code.
Basically you're asking for a "PUSH" functionality from server to client, and in that case you can't make use of HTTP.
Some tricks exist to work around this limitation, but basically they're all issuing requests at a certain frequency (Dave's answer does exactly that). If your site doesn't change that much, that means a lot of requests are issued for no reason (nothing has changed), consuming bandwith for nothing.
From what I know, the answer to this is called Websockets, which are supported by recent browsers only. I never had the chance to use it though so I couldn't tell much more about it. This allows full duplex communication, thus allowing server to "push" data to the client. I guess that's what SO uses for "new message" notifications (top left of the screen - you see immediately when you receive a new message)
My solution: I made a chrome extension that runs in the background and triggers the notifications. It's a little limited in scope as you need to have chrome to do it, but it does what i need it to, and for the purposes of the problem i'm working on, i can just make my user group use chrome ;D
The specifics: The extension only has two components, the manifest and a script. Currently, i setup the manifest so that it only works on my site using the match identifier... and i set the permissions to include notifications.
The JS script has a window.setinterval that looks for an element in the page with the id NOTIFIER. If it's empty, it does nothing, otherwise it creates a notification based on the content and then clears the content to prevent showing the same notification multiple times... (I tried using .onchange for that element, but couldn't get the event to trigger... I'd prefer to do this on an event rather then setInterval)
Notify.js
function onExtLoad() {
var timer = setInterval(refresh,1000);
}
document.addEventListener('DOMContentLoaded', onExtLoad());
function refresh() {
if (document.getElementById('NOTIFIER').innerHTML == "") {
//do nothing?
} else {
var notification = webkitNotifications.createNotification("",
"You got a new message",
document.getElementById('NOTIFIER').innerHTML);
notification.show();
document.getElementById('NOTIFIER').innerHTML = "";
}
}
Then, all i need to do is have the JS on the page control when it adds info the the NOTIFIER and voila! notifications!
Hope this helps someone else.
#ExpertSystem: I messed around with the MutationObserver but I can only get it to trigger once. Here's a JSFiddle: http://jsfiddle.net/BTX8x/1/
Am I missing something? Is there a way to reset it?
EDIT: Figured it out, i needed subtree:true

CodeIgniter destroying my session without

So, my current task involves a site where people can sign in, and view a series of training videos on a particular topic. I developed this within CodeIgniter. The only trouble is that once I have them log in, and I create a session, that session seems to mysteriously disappear after a few minutes, and they're mysteriously bounced back to the login page (which is what happens if someone is on the training video page without being signed in. This is the block of code in my config.php page:
$config['sess_cookie_name'] = 'cc_session';
$config['sess_expiration'] = 0;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'cc_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 3000000;
Why is sess_time_to_update set so high? At first, I thought that was the culprit, updating the session after 5 minutes. I have set the session to record to a database, and all that good stuff. Please, ask me questions, and help me get to the bottom of this!
I should point out that I have an iFrame that is on the course page that is sending a "ping" back to a server this way...
<iframe id="timerAddEnd" style="display:none;" src="http://www.example.com/course/finish/<?=$course->intKey?>/ping" >
</iframe>
<script type="text/javascript">
var auto_refresh = setInterval( function ()
{
var iframe = document.getElementById('timerAddEnd');
iframe.src = iframe.src;
}, 60000);
// refresh every minute
</script>
Could THIS be the culprit? I was hoping this would be a quick and dirty fix to the initial problem.
Are you using Firefox and Firebug with extensions (like FirePHP) installed? Because if you are having such a setup, when you open/close the Firebug console, the user-agent string changes, and your session is no longer recognized by CI.
My workaround was to disable FirePHP. Try checking your user-agent string and see if you have something extra besides the default browser user-agent. You should be able to identify it easily. if there is one.
Well, this may not be a full "answer" per se, but I did come up with a workaround of sorts.
I knew that the problem involved CodeIgniter handling sessions with... how do I put it... stuff running in the background. Originally I was using a CI page within the iFrame. Those "pings" back to the system were what was causing the lockout. So, I now use a regular, flat ol' PHP page within the iFrame. It connects to the database, but doesn't go through CI to do it. I get my "pings" to the table in question, but I don't break the session.
I had the same problem with session data getting "randomly" destroyed in CodeIgniter and I spent alot of time finding out what was wrong. Now I think i found MY problem, and it seemed as the $this->session->set_flashdata was the culprit.
I noticed that I got logged out on pages where this were used. I also noticed that if you do:
$this->session->set_flashdata('thisItem', 'value');
and later on the same page have the same variable again:
$this->session->set_flashdata('thisItem', 'new value');
then it will destroy the session data every time. Now I removed all the set_flashdata from my site, I havent been logged out since.. hoping this was my problem. When I have the time I will try to rewrite my flashing system to maybe something like if (!isset('thisItem)) { set it; } and stuff like this to prevent it from happening again, because I really want the flash messages.

Categories