I created a POST endpoint in the appengine flexible environment (Java/Spring Boot). It is in the same Google project as the PubSub subscriptions.
I checked and this POST endpoint is accessible from outside world. I can post data to this endpoint using Postman from my local PC.
But my controller does not get the requests from the push subscription.
I tried the simple endpoint urls like /push and also the recommended urls like /_ah/push-handlers/push but the results are the same.
I can see in the Stackdriver logs a lot of messages:
{
metadata: {
projectId: "myproject"
serviceName: "appengine.googleapis.com"
zone: "us-central1-b"
labels: {…}
timestamp: "2016-12-06T19:17:51.922Z"
}
insertId: "1u1o1hqf77guah"
log: "appengine.googleapis.com/nginx.request"
structPayload: {
method: "POST"
latencySeconds: "0.000"
referer: "-"
host: "-"
user: "-"
code: "307"
remote: "130.211.3.227"
agent: "-"
path: "/push"
size: "180"
}
}
But my push controller is never called.
When I post to this URL from Postman, I get similar 307 redirect (the only difference in the agent) and then after my controller responds I can see the 200 response:
{
metadata: {
projectId: "myproject"
serviceName: "appengine.googleapis.com"
zone: "us-central1-b"
labels: {…}
timestamp: "2016-12-06T19:10:14.226Z"
}
insertId: "1acos4zf74fb5r"
log: "appengine.googleapis.com/nginx.request"
structPayload: {
method: "POST"
latencySeconds: "0.035"
referer: "-"
host: "-"
user: "-"
code: "200"
remote: "130.211.0.196"
agent: "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36"
path: "/push"
size: "727"
}
}
Here is my app.yaml
# [START appyaml]
runtime: java
env: flex
runtime_config:
jdk: openjdk8
manual_scaling:
instances: 1
handlers:
- url: /.*
script: this field is required, but ignored
secure: optional
# [END appyaml]
What can be wrong?
I also had faced same problem.
I had a scala akka-http app on GAE flex.
I think that this is a bug of flex because I got success when I edited the push-endpoint on GAE Standard(golang).
There was a bug but...
As of today the issue has been resolved. Thank you for your patience.
Source: https://code.google.com/p/cloud-pubsub/issues/detail?id=49#makechanges
Related
For some reason trying to do a POST request on safari doesn't work despite it working on chrome for me. https://caniuse.com/#search=fetch suggests that fetch should work on safari, and the GET requests do work just fine.
My code looks like
putData() {
let data = {
title: this.state.tempTitle,
lat: this.state.tempLat,
lng: this.state.tempLng,
insta: this.state.tempInsta,
icon: this.state.tempType,
approved: false,
};
let options = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
mode: 'cors',
body: JSON.stringify(data),
};
fetch("/items/", options);
}
Other similar/same questions on stack overflow suggested adding the mode: 'cors' line as well as changing /items to /items/ but, I have tried without those two changes to my code as well.
Response preview on safari says An error occurred when trying to load resource and the request headers page for items/ shows
Summary
URL: http://localhost:3000/items/
Status: —
Source: —
Initiator:
Suggest.js:62
Request
Content-Type: application/json
Referer: http://localhost:3000/suggest
Accept: */*
Origin: http://localhost:3000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15
Response
No response headers
Confused as to why this might be happening, didn't even notice till I uploaded the site to AWS and someone using it noticed on their iPhone.
I have started using 'Artillery.io for load testing. Here how to pass authentication parameters like email, password in the load-test.yml, the below throws 401 an unauthorised error while sending the request. Could someone guide me on how to pass authentication parameters like email and password
config:
target: 'https://test-url.com'
phases:
- duration: 70
arrivalRate: 10
defaults:
headers:
Content-Type: application/json
scenarios:
- flow:
- get:
url: /findAMembership
headers:
Content-Type: application/json
- post:
url: /auth
body: '{"username":"test#test.com", "password": "some_testpassword"}'
headers:
Content-Type: application/json
There are something to do with your script that makes it much easier to read, troubleshoot and maybe solve your problem.
First, about the 401 problem, I think your request does not meet the authentication endpoint requirements. Please check the endpoint. (like how to do the auth in a normal way?)
I assume that the endpoint accepts an json request (username and password) and response a Bearer token, you can try this (use json instead of body, and define the key-value):
- post:
url: "/auth"
json:
username: "test#test.com"
password: "some_testpassword"
headers:
Content-Type: "application/json" # no need this, you have specified the default Content-Type
capture:
json: "$.token"
as: "token" # Should have this, read below
And just a note, you sent an auth request and do not capture anything from it, which makes no sense. Remember to capture the response (like Bearer token, etc.) for chaining requests that need the authentication. Read more
If you want to read the users from file, you can specify a payload path, and it's fields. This also allowed you to test scenarios where you have several users, and/or failed attempts.
config:
target: "<TARGET>"
payload:
- path: "./users.csv"
fields:
- "username"
- "password"
order: sequence
skipHeader: true
- path: "./products.csv"
fields:
- "id"
order: sequence
skipHeader: true
phases:
- duration: 60
arrivalRate: 20
scenarios:
- flow:
- post:
url: "/login"
json:
username: "{{ username }}"
password: "{{ password }}"
This way the username and passwords will be read from the specified CSV- file and POSTed to the <TARGET>/login endpoint with the json body object
{
username: <READ USERNAME>
password: <READ PASSWORD>
}
An example CSV- file may look like
username,password
some1#example.com,super1
email#example.com,secret
I am trying to deploy my react express app on google app engine. Everything works fine on localhost but when I deploy I get a 404 error:
I assume this could be something wrong with my handlers but i'm not to sure, help would be much appreciated.
Cannot GET /
Failed to load resource: the server responded with a status of 404 ()
This is what the console log says:
httpRequest: {
latency: "0.006s"
referer: "-"
remoteIp: "2001:8000:11d3:ed00:4854:5aba:9f93:dd47"
requestMethod: "GET"
requestUrl: "/"
responseSize: "139"
status: 404
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36"
}
insertId: "ezhqr2g2ohjlxu"
jsonPayload: {
appLatencySeconds: "0.004"
httpRequest: {
protocol: "HTTP/1.1"
}
latencySeconds: "0.006"
trace: "dd9ffc275b4f1457905cf864bf17539c"
}
labels: {
appengine.googleapis.com/instance_name: "aef-web--form-20190524t155912-31cn"
appengine.googleapis.com/trace_id: "dd9ffc275b4f1457905cf864bf17539c"
compute.googleapis.com/resource_id: "1391234725058328108"
compute.googleapis.com/resource_name: "a68af8bf7290"
compute.googleapis.com/zone: "australia-southeast1-b"
}
logName: "confidential"
receiveTimestamp: "2019-05-26T22:36:57.374278865Z"
resource: {
labels: {
module_id: "web-form"
project_id: "confidential"
version_id: "20190524t155912"
}
type: "gae_app"
}
timestamp: "2019-05-26T22:36:54.837Z"
trace: "confidential"
}
and here is my yaml file:
service: web-form
runtime: nodejs
env: flex
automatic_scaling:
min_num_instances: 1
max_num_instances: 1
env_variables:
PROJECT_ID: 'project'
handlers:
- url: /*
secure: always
redirect_http_response_code: 301
script: auto
resources:
cpu: 1
memory_gb: 1.7
disk_size_gb: 10
volumes:
- name: ramdisk1
volume_type: tmpfs
size_gb: 1
I am new to AngularJS, I am from SAP background and as part of my PoC I built my REST services using SAP NW Gateway,I am facing an issue to POST data from Angularjs to my REST services.Please find the below detailed error log
***1. Remote Address:
10.xxx.xx.xx:8000
2. Request URL:
//host:port/sap/opu/odata/sap/USERS/Users
3. Request Method:
POST
4. Status Code:
400 Bad Request
5. Request Headersview source
1. Accept:
application/json, text/plain, */*
2. Accept-Encoding:
gzip,deflate
3. Accept-Language:
en,te;q=0.8
4. Authorization:
Basic a2VsYW1yOmoyZDEwMA==
5. Connection:
keep-alive
6. Content-Length:
146
7. Content-Type:
application/json;charset=UTF-8
8. Cookie:
sap-usercontext=sap-client=100; SAP_SESSIONID_J2D_100=R_60WyUyNG2nV1MbhC9QAcKPzyBwwxHkmwsAUFaDBqQ%3d
9. Host:
abcdefgh:8000
10. Origin:
file://
11. User-Agent:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36
12. X-CSRF-Token:
_jXDnt2Cdpplpj5zvK3iPA==
6. Request Payloadview source
{UserID:555, FirstName:rajesh555, LastName:kelam555, Email:rajesh555#gmail.com, Phone:9876554433,…}
1. Country: "UK"
2. Email: "rajesh555#gmail.com"
3. FirstName: "rajesh555"
4. LastName: "kelam555"
5. Phone: 9876554433
6. Postcode: "TW18 4BL"
7. UserID: 555
7. Response Headersview source
1. content-length:
535
2. content-type:
application/json
3. dataserviceversion:
1.0****
Angular Code for Post :
$scope.addRow = function () {
var config = {};
var pushdata = {'UserID':$scope.UserID, 'FirstName':$scope.FirstName, 'LastName':$scope.LastName, 'Email':$scope.Email, 'Phone':$scope.Phone, 'Country':$scope.Country, 'Postcode':$scope.Postcode};
// Sending Notification to User
growl.addSuccessMessage("User Created", config);
/* $http.post(url,pushdata, {'Content-Type':'application/json'}).success(function(pushdata) {
$scope.resultSet = pushdata.d.results;
alret("Data Posted");
}) */
$http.post(url,pushdata, {headers:{'Content-Type':'application/json'}}).success(function(data){alert(data);});
$scope.resultSet.push(pushdata);
$scope.createMessage();
$scope.UserID='';
$scope.FirstName='';
$scope.LastName='';
$scope.Email='';
$scope.Phone='';
$scope.Country='';
};
it would be great if some one help me to sort.
*Note: I am a kid in AngularJS...please ignore me and feel free to thought me.
I request to suggest the best URl/Site to learn Angularjs in a better and consistent way.
I thought, if I share the format(XML/JSON) of payload expecting for the POST to perform by my SAP Gateway service which will helps me to quickly resolve this.Below are the formats of XML/JSON works for POST.
XML Format:
host:port/sap/opu/odata/sap/USERS/Users('123')
Users('123')
2014-11-21T15:21:52Z
123
RAJESH
KELAM
RAJESHKUMAR.KELAM#ABG.CO.UK
123456789
UK
RG4 6SA
JSON Format:
{
d:
{
__metadata:
{
id: "host:port/sap/opu/odata/sap/USERS/Users('123')"
uri: "host:port/sap/opu/odata/sap/USERS/Users('123')"
type: "USERS.User"
}
-
UserID: "123"
FirstName: "RAJESH"
LastName: "KELAM"
Email: "RAJESHKUMAR.KELAM#ABG.CO.UK"
Phone: "123456789"
Country: "UK"
Postcode: "RG4 6SA"
}
-
}
You sure that the url you posting is expecting this data you want to post? You can use POSTMAN extension (in google chrome) and test if you service are ready to receive any data from http.post
Finally I could able to sort out my problem, it is all about formatting the data passing to REST service..
below is the peice of code which works is my case
$scope.addRow = function () {
var StrUId = ($scope.UserID).toString();
var StrPh = ($scope.Phone).toString();
var pushdata = {"UserID":StrUId, "FirstName":$scope.FirstName, "LastName":$scope.LastName, "Email":$scope.Email, "Phone":StrPh, "Country":$scope.Country, "Postcode":$scope.Postcode};
// Posting data
$http({
method: "post",
url:url,
data:pushdata,
headers: {
"X-CSRF-Token": "0XGo8HzpzrhaZxxX83QH9g==",
},
dataType : "json",
async: false,
contentType: 'application/json',
success: function(data){
alert(data);
}
});
Thanks for the support given
Rajesh
I'm trying to make an Ajax post request from Backbone, calling the Laravel route "pay" but I get always this answer from the console log:
XMLHttpRequest cannot load https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=EC-5S932878HU8059629. Origin http://localhost is not allowed by Access-Control-Allow-Origin.
I tried to modify my MAMP httpd.conf to accept cross domain script, and as you can see I've added an header instruction to the routes.php.
Here is my JS code:
Backbone.ajax({
url:'index.php/pay',
type:'POST',
dataType:"json",
data: converteditems,
crossDomain: true,
success:function (data) {
if(data.error) { // If there is an error, show the error messages
$('.alert-error').text(data.error.text).show();
}
}
});
This is the routes.php in Laravel:
<?php
header('Access-Control-Allow-Origin: *');
Route::get('/', function()
{
return View::make('home');
});
Route::resource('products','ProductsController');
Route::resource('login', 'AuthenticationController');
Route::post('pay','PaypalController#doPay');
The doPay method use the Omnipay package in this way (for testing purpose ofc):
public function doPay()
{
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername('blablablabla-facilitator_api1.gmail.com');
$gateway->setPassword('137787773');
$gateway->setSignature('AhFvPK5rU.kfQOKIwZcYO1yItmtHASGDFDFGDbY9.w');
$gateway->setTestMode('true');
$args['amount']='2.00';
$args['description']='Your purchase';
$args['returnUrl']='http://localhost/shoppingcart/index.php/return';
$args['cancelUrl']='http://localhost/shoppingcart/index.php/cancel';
try {
$response = $gateway->purchase($args)->send();
if ($response->isSuccessful()) {
$responsereturn=$response->getData();
} elseif ($response->isRedirect()) {
$response->redirect();
} else {
exit($response->getMessage());
}
} catch (\Exception $e) {
exit('internal error, log exception and display a generic message to the customer');
}
}
Some more info from the headers of my console:
Request URL:http://localhost/shoppingcart/public/index.php/pay
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Origin:http://localhost
Referer:http://localhost/shoppingcart/public/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
Request URL:https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=EC-6J290181UP558705C
Request Headersview source
Origin:http://localhost
Referer:http://localhost/shoppingcart/public/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.69 Safari/537.36
Query String Parametersview sourceview URL encoded
cmd:_express-checkout
useraction:commit
token:EC-6J290181UP558705C
If you want to make your request from Ajax, then you don't want omnipay to immediately redirect that request to paypal. You want to redirect the customer'a browser to paypal.
So you need to put some logic in your controller action, so if it is an XHR request, then just return the URL to forward the customer to.
E.g. Use $response->getRedirectUrl() on the omnipay response instead of $response->redirect(). Then put that in a JSON response or something and use JavaScript to send the customers browser to that URL.