Self hosted SignalR client method not invoked - angularjs

I know this issue has been treated before since I have googled and read most of the responses of people who have had the same or similar problem in the past. None of them have been the solution for my case. The problem I have is my client method is not getting called and I have already defined the client method before starting the hub. When I do that I get another error but when I define the method after starting my hub, I don't get an error but then my client function does not get fired.
I think, the fact that I am self-hosting in a Win service using static files serving or because I am using AngularJS, that's why I am having this problem. but I am not really sure.
Can you help me? Any suggestions? Of course I have gone through the SignalR troubleshooting guide several times. I have checked the name of my client method to make sure all is correctly named but still this problems rears it head. I would like to believe the fact that its because I am self hosting or because of Angular . I know that when I define my client method before starting the hub, the hub tries to setup subscriptions to the signal service and when it tries to do so fails because it cannot find (my assumption) the hub which is defined (Hub name: OffiHub) in a folder (/OffiSignalR/Hubs).
I get the following error when I debug using Chrome: jquery-2.2.1.js:9175 GET http://localhost:36900/OffiG/start?transport=serverSentEvents&clientPD%3D&connectionData=%5B%7B%22name%22%3A%22offihub%22%7D%5D&_=1459195567970 500 (Internal Server Error)
In case you wish to see my code, here it is:
var offiHub = $.connection.offiHub;
offiHub.client.publishSales = function (so) {
//Add to the current list.
console.log("We got here!");
log('We got here, hurray!.');
};
$.connection.hub.start().done(init);

I have found the answer to my problem. It was all my fault, I had a code snippet in the OnConnected method on the server which was failing when I try to connect to the service from the client. I had placed the code there for when I would need it but hadn't thought much about it. This code has given me much grief these past few days. Remove it and all is working well from all clients. In fact it was the .Net client that made me suspect the faulty code.

Related

Java IOException during API request to Stripe (APIConnectionException)

The specific action we are trying to performe is to create a charge request with Stripe:
Charge charge = Charge.create(params);
Using Stripe's Java implementation (version 5.35.1) we encounter a APIConnectionException when running the application on the deployed App Engine server. Interestingly, the issue does not occur using App Engine's local dev server.
We contacted Stripe and they said everything is fine on their side. They explained that "this error indicates that your server is not able to contact our API and that it ends up timing out waiting for an answer. Usually, this is due to something misconfigured on your server such as a DNS not redirecting to Stripe properly."
We were wondering if there are some configuration settings on App Engine which cause the problem. However, since there is no specific error message we cound not figure out what might cause the connection problem.
Similar problems which did not provide enough help to resolve this issue: https://issuetracker.google.com/35901039
Thanks for your help!
The problem seems to have solved itself. It occured for a couple of days and since a few hours the exact same code is working fine. Just like in https://issuetracker.google.com/issues/35901039 the problem is suddenly gone for some reason.

NullPointerException with JDBC and App Engine

I have been struggling with a problem in Google App Engine, using Java, for several days.
Many times (about 50% of the time) when I try to request the connection to a Cloud Sql instance, the connection returns a null value, resulting in several NullPointerException messages when trying to invoke Cloud Sql queries (when invoking .prepareCall(stored_proc)).
I have the latest App Engine Java SDK, in a project service, shared with other services built in Python which consume this Java backend.
Could it be possible that after certain time the instance/s could crash (I am just testing at this point, so I am using default scalation)?
This is the code that returns null:
Class.forName("com.mysql.jdbc.GoogleDriver");
url = "jdbc:google:mysql://project:instance/database?user=root";
log.info(url);
return DriverManager.getConnection(url);
This is part of my configuration file:
<application>app</application>
<module>mod</module>
<version>1</version>
<threadsafe>true</threadsafe>
<use-google-connector-j>true</use-google-connector-j>
I tried several suggestions from other posts, but with no success at all.
Any suggestion will be welcome, thanks in advance.
I was facing the same problem while using Google Cloud SQL and App engine.
I solved the problem by managing the connection pool my self. I realised that when you request a new connection for each request and close it on completion of the thread. The other requests would get back a null resulting to NullPointException.
I decided to do the following and it work for me for like 2 years now.
Open a connection and keep it to a static class that has a number of connections;
Every time i want to find a connection to the database, i would first check if the is an available connection for me to use.
Incase a Query killed the connection, thus means i needed to request another extra connection just to for the sack of connection drops.
I will add this as an answer, since it is not exactly what Chrispinus mentioned, although he gave me a good idea for teh solution.
I went deeper in the code and found that some of the methods were not closing the database connection. I had assumed all of them were doing that, but looking at each method, I found I was wrong.
So, although it sounds obvious, check connections are being closed (or managed, as Chrispinus says) properly.

appengine.google.com & objectify - working ok locally but not on gae?

I am developing a backend using Android Studio and Java.
I use objectify to manipulate entities in Google's Datastore.
The question is the following: everything works ok locally. I can call any of the endpoint and add, update and delete entities. However, anything to do with the same entities do not seem to work on GAE... Is there anything specific required for this to work?
Logs are fairly limited also but it appears all endpoints register properly.
The only thing meaningful out of the GAE and logs section is for return calls being set to 200 but nothing more....
Thoughts? Thanks.
I was looking at the google public issue tracker and saw your code posted there (I am also editing your answer to add said code). I can't help but notice that in your "test.html", you load the function from "localhost:8080". This will obviously break your code whenever you're using it on a client's machine, because it will try to load the function from HIS localhost, which won't have your function in it.
When you're running your code on your production server, you would need to use something like "your-end-point.your-application.appspot.com" to get your function.
Also, I think that you can ONLY pass around either JSON or "JavaBeans" object. And it seems the "Test" you are passing isn't a JavaBeans (it has a constructor with at least a parameter).
The fact it never loads the function properly could also explain why your Logs don't show.

Problems using Twitter4j on GAE throws 401 just after deploy

Well, I'm having a weird error here:
I'm developing one GAE app to read some Twitter Data, and after read a lot of docs, I have it working on my test server (Running on my pc) but after deploy and test on the real (my appspot domain) it shows this message:
401:Authentication credentials (https://dev.twitter.com/pages/auth) were missing or >incorrect. Ensure that you have set valid consumer key/secret, access token/secret, and the >system clock is in sync.
message - Could not authenticate you
code - 32
I've tried to recreate my OAuthAppToken and OAuthAppTokenSecret keys, even changing the permissions to "Write, Read and Direct Messages" and even assingning one Callback URL but nothing seems to work...
I've tried using twitter4j.properties OR using setOAuthConsumer(TW_CONSUMER_KEY, TW_CONSUMER_SECRET) OR a ConfigurationBuilder whith the correct constants and I'm experimenting the same Issue.
I'm working with AppEngine 1.8.3 and Twitter4j 3.0.4
Iv'e been writing on log and the Twitter object seems to be well created... I dont understand why is working on my PC but not on the real app.
On some other post someone says that could be because it needs to use Sync clock.. but he doesn't explains where to change that property...
Did someone had a clue?
Ok, the problem was me (and Twitter.... well..... I really think it was Twitter problem for being so dark on his api messages)...
On testing server I was looking for an existing account and on the cloud I was looking for an inexistent one. So, It was my mistake. But seriously, what about Twitter saying: "Access Forbidden"? That doesn't have any sense...

How do I setup a really simple WCF Data service and entity model that works?

Ok this is going to seem really daft but but essentially this is what i'm trying to do in a nutshell ...
http://msdn.microsoft.com/en-us/library/dd465161.aspx
The problem is that when I create the WCF Data Service and browse to it everything looks good at the root level and as soon as I leave the root I get http 500 errors.
I get no decent information on how to fix the error or what went wrong it says "Internal server error" ... not helpful.
So my question is sort of twofold ...
How do I setup a simple WCF Data service that relies on an entity model then bind some simple data to a listbox or something in a WPF client?
but also ...
How do I debug those http 500 errors?
Just for clarification:
I followed the steps here ...
http://msdn.microsoft.com/en-us/library/dd728275.aspx
... to create the model and service.
The root url "http://localhost/Northwind.svc" works fine.
Browsing to "http://localhost/Northwind.svc/Orders" causes a http 500.
This helps a LOT:
Link
Also download fiddler you can use it to monitor requests/responses (See this)
I would start by attaching the debugger to your service when you use your browser to access it.
You might want to try a different client because there usually is a response from a service besides the 500 errorcode, but a browser only shows a 500 error page.

Resources