I'm relatively new at Elixir and Phoenix (which is probably the reason I have no idea what's going on).
I'm trying to set up Ueberauth on a Phoenix app with Google authentication.
I followed the sample app https://github.com/ueberauth/ueberauth_example as faithfully as I could figure.
I prepared the app for Heroku like the Phoenix docs say. The home page shows up properly. When I click on my button to start the auth process, I get as far as Google and Google asks me if I do want to authenticate. When I click yes, I get an internal server error and I don't really know what's going on with it.
Here's what I have in the logs:
2016-03-24T04:02:14.429507+00:00 app[web.1]: 04:02:14.429 [error] #PID<0.364.0> running GreatStrides.Endpoint terminated
2016-03-24T04:02:14.429520+00:00 app[web.1]: Server: MYHEROKUAPP:80 (http)
2016-03-24T04:02:14.429521+00:00 app[web.1]: Request: GET
/auth/google/callback?code=ACODEGOESHERE
2016-03-24T04:02:14.429522+00:00 app[web.1]: ** (exit) exited in: :gen_server.call(:hackney_manager, {:new_request, #PID<0.364.0>, #Reference<0.0.1.2373>, {:client, :undefined, {:metrics_ng, :metrics_dummy}, :hackney_ssl_transport, 'accounts.google.com', 443, "accounts.google.com", [], nil, nil, nil, true, :hackney_pool, 5000, false, 5, false, 5, nil, nil, nil, :undefined, :start, nil, :normal, false, false, false, :undefined, false, nil, :waiting, nil, 4096, "", [], :undefined, nil, nil, nil, nil, :undefined, nil}}, :infinity)
2016-03-24T11:54:59.195968+00:00 app[web.1]: ** (EXIT) no process
What's going on here?
This should be a comment, but it was too long.
Do you have any other errors? Because this looks incomplete.
When something is wrong in Elixir application, supervision tree makes sure that all processes that encountered the error die. That is why you can see the first line GreatStrides.Endpoint terminated.
Second and third line is just a normal log.
Fourth line is an error calling gen_server. It prints the function call with all three arguments: server, request, timeout. You can inspect arguments if they are correct, but those are some internals of hackneys client record. GenServer client just waits for answer here for infinite amount of time - nothing should go wrong.
This means there should be another crash report from inside GenServer. It can be similar to previous one. There you should be able to find actual reason. If the GenServer crashes while doing its work, all clients waiting for answer are notified that it exited.
EDIT: After edits by #Trevoke
The problem was that the hackney gen_server was not running and this caused the error. Checking with Application.loaded_applications proved that hackney application is not running at all and it needs to be added to applications section in mix.exs.
Related
We try to do acknowledge google play purchase on the server-side through purchases.products.acknowledge with golang
However, the following errors come up sometime
googleapi: Error 409: The operation could not be performed since the object was
already in the process of being updated., concurrentUpdate
googleapi: Error 400: The purchase is not in a valid state to perform the desired operation
Is there anything am I missing? or how to solve those errors?
Per google support
For error 400, the purchaseState must be Purchased or 0 before you can acknowledge the purchase. For more information, please refer to this page: https://developer.android.com/google/play/billing/integrate#process
Error 400 can also mean that you already acknowledged the purchase.
For error 409, this means you are acknowledging the purchase multiple times concurrently. Unfortunately, we don't provide support for API concurrency issues.
Currently having this exactly issue, did you manage to resolve it in the end.
Acknowledgement Request Response: {
error: {
code: 409,
message: 'The operation could not be performed since the object was already in the process of being updated.',
errors: [ [Object] ]
}
}
I'm only sending it once, after i have validated and added to my database. I'm not sure why its happening.
EDIT:
I had a theory my code was executing to fast and maybe the order was still pending, so i added a 10 second gap between getting purchase token and then trying to acknowledge once again. Im now getting the following.
Acknowledgement Request Response: {
error: {
code: 400,
message: 'The purchase is not in a valid state to perform the desired operation.',
errors: [ [Object] ]
}
}
However at this time in Google Play Console, the state is Chargeable, meaning it just needs to be acknowledged.
I have a Linux machine (IP: 10.0.0.33), in which I run netcat as a listener on port 4444. I also have a Windows 10 machine that I connect to the Linux machine with the TCPSocket class.
I wrote a code in order to help me understand how IO.select works with the socket object and the IO objects STDIN and STDOUT, but I just can't figure this out.
Here is my code:
require 'socket'
socket = TCPSocket.open("10.0.0.33", 4444)
while true
IO.select([socket], nil, nil) #I'm changing the arguments in this line
puts(1)
socket.gets.chomp
puts(2)
sleep(1)
end
As I expected, if I run the above code nothing happens until I send a message from the Linux machine. When I do, the 1 and 2 are printed, and then again nothing happens until I send another message from Linux (as I expected).
But, if I change only the IO.select line to
IO.select(nil, [socket], nil)
The 1 is printed immediately, and I don't understand why.
If I cahnge this line to anyone of the following:
IO.select(nil, [STDIN], nil)
IO.select(nil, [STDOUT], nil)
IO.select([STDOUT], nil, nil)
The 1 is printed immediately.
Why everytime I put something in the output array argument of the IO.select function, IO.select doesn't wait?
I thought it should find an IO stream with some data ready to be sent through, but I send nothing in this program.
Also, why putting STDOUT in the input array argument of the IO.select function behaves the same way?
I have a web-page (Django 1.9 on back-end, Apache server) with an endless-paginated table with large data set and column filters. When a user activates one filter (let's denote it CHOICE 1), and then instantly changes his mind resetting the filter (let's refer to it as CHOICE 2), I would like to tell Ajax to give up waiting for back-end response to CHOICE 1 and go on to posting and waiting for CHOICE 2 request. For this purpose, I had the following JS code:
// AJAX_GET_REQUEST is a global variable
AJAX_GET_REQUEST= $.ajax(
{
type:'GET',
url:"/my_url/",
beforeSend : function()
{
if (AJAX_GET_REQUEST!= null)
AJAX_GET_REQUEST.abort();
},
data:data,
success: function(response)
{
// Do something
}
});
Fine. I used to think that I achieved the goal of successfully canceling irrelevant requests, But I found out that AJAX_GET_REQUEST.abort(); leads to Django error [Errno 10053] An established connection was aborted by the software in your host machine. The interesting think is that this is not a 'fatal error' in that the app does not terminate, but rather it takes years for my paginated table to load. Django seems to reactivate connection itself and go on to handle last request. Finally after waiting for long time I see the correct result on front-end. If I remove the AJAX_GET_REQUEST.abort(); line, everything is fine, but I have to wait until Django is through with irrelevant requests until it goes on to handle the last relevant request.
Is there any way out? Is it possible to abort previous requests avoiding this annoying 10053 error ?
I'm trying to use the Go pubsub library against the local emulated pubsub server. I'm finding that the "old style" (deprecated) functions (e.g. CreateSub and PullWait) work find, but the "new style" API (e.g. Iterators and SubscriptionHandles) does not work as expected.
I've written two different unit tests that both test the same sequence of actions, one using the "new style" API and one using the "old style" API.
The sequence is:
create a subscription
fail to pull any messages (since none available)
publish a message
pull that message, but don't ACK it
lastly pull it again which should take 10s since the message ACK timeout has to expire first
https://gist.github.com/ianrose14/db6ecd9ccb6c84c8b36bf49d93b11bfb
The test using the old-style API works just as I would expect:
=== RUN TestPubSubRereadLegacyForDemo
--- PASS: TestPubSubRereadLegacyForDemo (10.32s)
pubsubintg_test.go:217: PullWait returned in 21.64236ms (expected 0)
pubsubintg_test.go:228: PullWait returned in 10.048119558s (expected 10s)
PASS
Whereas the test using the new-style API works unreliably. Sometimes things work as expected:
=== RUN TestPubSubRereadForDemo
--- PASS: TestPubSubRereadForDemo (11.38s)
pubsubintg_test.go:149: iter.Next() returned in 17.686701ms (expected 0)
pubsubintg_test.go:171: iter.Next() returned in 10.059492646s (expected 10s)
PASS
But sometimes I find that iter.Stop() doesn't return promptly as it should (and note how the second iter.Next too way longer than it should):
=== RUN TestPubSubRereadForDemo
--- FAIL: TestPubSubRereadForDemo (23.87s)
pubsubintg_test.go:149: iter.Next() returned in 7.3284ms (expected 0)
pubsubintg_test.go:171: iter.Next() returned in 20.074994835s (expected 10s)
pubsubintg_test.go:183: iter.Stop() took too long (2.475055901s)
FAIL
And other times I find that the first Pull after publishing the message takes too long (it should be near instant):
=== RUN TestPubSubRereadForDemo
--- FAIL: TestPubSubRereadForDemo (6.32s)
pubsubintg_test.go:147: failed to pull message from iterator: context deadline exceeded
FAIL
Any ideas? Are there any working examples using the new-style API? Unfortunately, the Go starter project here uses the old, deprecated API.
(Note: It looks like the line numbers in your example output don't match the code that you've linked.)
But sometimes I find that iter.Stop() doesn't return promptly as it should
A few changes have landed recently which fix the excessive delay when calling iter.Stop. It should now return promptly if all messages have been acked. Try syncing and testing it out again.
(and note how the second iter.Next too way longer than it should):
In you code that uses the new API, you first do a pull from an empty subscription, using a context with a 1s deadline. Let's call this "Pull request A". Although the underlying http request is cancelled, it seems that the connection is not being closed in any way that the server respects. So, as far as the server is concerned, "A" is still pending. Immediately after publishing, you make a new pull request, let's call that "B". After a message is returned via pull request B, you leave the message unacked, and make another pull request, "C".
Now, when you publish the message, the server will deliver it to either "A" or "B". If it delivers it to "A" first, you will see the first pull exceeding the 5s context deadline. If it is published to "B" first, you will see the first pull returning quickly, as expected. After the message is published to "B", and left unacked, the server will redeliver it to "A", or "C". If it picks "A" first, then you will end up with the second pull taking longer than expected. If it picks "C", then you will see both first and second pulls taking as long as you expect.
If you don't do that initial pull from the empty subscription, you should see your test behave as you expect.
Note: You don't see any of this when you use the old API because you're not doing the extra "pull from empty subscription" request with the old API (presumably because it doesn't properly support a cancellable context).
Aside: if you want to leave a message unacked, you should call Message.Done(false).
Friends,
I have a non-blocking TCP socket (on AIX). When I attempted connect() I got EINPROGRESS. My question is if I call recv() before connection completion, what would be the (most apprpriate) error code?
I saw that, in case connection fails, and I call recv(), I got ECONNREFUSED; means I got an error corresponding to my earlier connect() attempt. Taking same logic I should get EINPROGRESS for recv(). Am I right in my approach ?
If yes, this raises another question - Why such error codes are not included amongst error codes of recv()?
I have only seen EAGAIN returned in this case, just as you would see in the case where there's no data to read. For writing to a non-connected socket, you typically get ENOTCONN, though I believe some platforms might give you EAGAIN.
Here's a trivial Python script to demonstrate:
import socket
# Any address that does not succeed or fail right away will do
ADDR = "192.168.100.100"
PORT = 23
s = socket.socket()
s.setblocking(False)
try:
s.connect((ADDR, PORT))
except socket.error, e:
print "Connect gave us",e
try:
s.recv(1)
except socket.error, e:
print "Read gave us",e
try:
s.send("x")
except socket.error, e:
print "Write gave us",e
For me, it gives:
Connect gave us (36, 'Operation now in progress')
Read gave us (35, 'Resource temporarily unavailable')
Write gave us (57, 'Socket is not connected')
These are EINPROGRESS, EAGAIN, and ENOTCONN respectively.
You are operating on a non-blocking socket, which is perfect fine to return EINPROGRESS, which indict that the connection establishment has not being finished yet, this is documented in connect's page:
EINPROGRESS
The socket is nonblocking and the connection cannot be completed immediately. It is possible to select(2) or poll(2) for completion by
selecting the socket for writing. After select(2) indicates writability, use getsockopt(2) to read the SO_ERROR option at level SOL_SOCKET
to determine whether connect() completed successfully (SO_ERROR is zero) or unsuccessfully (SO_ERROR is one of the usual error codes listed
here, explaining the reason for the failure).
So you will need select/pool to make sure the socket is writable, and get error from SO_ERROR.