From past few days, i am getting the below error when i try to run the example python websocket flexible-app-engine application (https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/flexible/websockets). It use to work before but now when i run, i see the below error.
I dont see this issue when i run locally using - "gunicorn -b 127.0.0.1:8080 -k flask_sockets.worker main:app".
I see this issue only when i deploy in google cloud.
File "/env/lib/python3.6/site-packages/gevent/pywsgi.py", line 999, in handle_one_response
self.run_application()
File "/env/lib/python3.6/site-packages/geventwebsocket/handler.py", line 75, in run_application
self.run_websocket()
File "/env/lib/python3.6/site-packages/geventwebsocket/handler.py", line 52, in run_websocket
list(self.application(self.environ, lambda s, h, e=None: []))
File "/env/lib/python3.6/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/env/lib/python3.6/site-packages/flask_sockets.py", line 40, in __call__
handler, values = adapter.match()
File "/env/lib/python3.6/site-packages/werkzeug/routing.py", line 2026, in match
raise WebsocketMismatch()
werkzeug.routing.WebsocketMismatch: 400 Bad Request: The browser (or proxy) sent a request that this server could not understand.
{
textPayload: "2021-05-14T22:33:23Z {'REMOTE_ADDR': '172.17.0.4', 'REMOTE_PORT': '23300', 'HTTP_HOST': 'malware-sandboxing.uc.r.appspot.com', (hidden keys: 39)} failed with WebsocketMismatch
"
insertId: "nn71n3jmo5u1ymw9s"
resource: {2}
timestamp: "2021-05-14T22:33:23Z"
labels: {4}
logName: "projects/malware-sandboxing/logs/appengine.googleapis.com%2Fstderr"
receiveTimestamp: "2021-05-14T22:33:26.911503907Z"
}
Please help
Werkzeug released version 2.0.0 which also broke things for me.
https://github.com/pallets/werkzeug/releases/tag/2.0.0
Added Werkzeug==1.0.1 to the top of requirements file fixed my issue.
Related
I created a small program in Python for reading messages from a Pub/Sub subscription. I am using Python 3.7 and google-cloud-pubsub 1.1.0.
My code is very simple:
from google.cloud import pubsub_v1
from google.auth import jwt
import json
service_account_info = json.load(open("service-account-info.json"))
audience_sub = "https://pubsub.googleapis.com/google.pubsub.v1.Subscriber"
credentials_sub = jwt.Credentials.from_service_account_info(
service_account_info, audience=audience_sub
)
subscriber_ring = pubsub_v1.SubscriberClient(credentials=credentials_sub)
def callback1(message):
print("In callback!!")
print(message.data)
message.ack()
sub_path = "projects/my-project/subscriptions/my-sub"
future = subscriber_ring.subscribe(sub_path, callback=callback1)
future.result()
When the code reaches "future.result()", it hangs there forever and times out 10 minutes later with the error
pubsub 503 failed to connect to all addresses
I already verified that:
Pub/Sub is up and running
My service account has all the needed permissions. I even tried with my personal Google Cloud account (I am the project owner) with the same results.
There are unacked messages in the Topic
My network connection is OK
but I cannot make it work. Any ideas?
EDIT: I got some more info from the exception:
om_grpc_error(exc), exc)
File "<string>", line 3, in raise_from
google.api_core.exceptions.ServiceUnavailable: 503 failed to connect to all addresses
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/loadtest/lib/python3.7/site-packages/google/cloud/pubsub_v1/publisher/_batch/thread.py", line 219, in _commit
response = self._client.api.publish(self._topic, self._messages)
File "/usr/local/anaconda3/envs/loadtest/lib/python3.7/site-packages/google/cloud/pubsub_v1/gapic/publisher_client.py", line 498, in publish
request, retry=retry, timeout=timeout, metadata=metadata
File "/usr/local/anaconda3/envs/loadtest/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py", line 143, in __call__
return wrapped_func(*args, **kwargs)
File "/usr/local/anaconda3/envs/loadtest/lib/python3.7/site-packages/google/api_core/retry.py", line 286, in retry_wrapped_func
on_error=on_error,
File "/usr/local/anaconda3/envs/loadtest/lib/python3.7/site-packages/google/api_core/retry.py", line 206, in retry_target
last_exc,
File "<string>", line 3, in raise_from
google.api_core.exceptions.RetryError: Deadline of 60.0s exceeded while calling functools.partial(<function _wrap_unary_errors.<locals>.error_remapped_callable at 0x7fa030891a70>,
, metadata=[('x-goog-request-params', 'topic=projects/my-project/subscriptions/my-sub'), ('x-goog-api-client', 'gl-python/3.7.6 grpc/1.26.0 gax/1.16.0 gapic/1.2.0')]), last exception: 503 failed to connect to all addresses
It is likely that there is a firewall rule in place or some network configuration that is disallowing/dropping connections to *.googleapis.com (or specifically pubsub.googleapis.com). You can see an example of this with another Google product.
I am getting below error while accessing the api via explorer '_ah/api/explorer' or when api is called from the app.
Below is relevant piece from app.yaml and api implementation.
From other questions on stackoverflow it looks like this could happen if endpoint config is not deployed using gcloud service-management but event after uploading gatewayv1openapi.json I am getting similar error.
Is there something i need to change in api code or app.yaml? One more thing is that I have uploaded exact same codebase (only difference is other project id instead of ixp-test in app.yaml) to another old project and it works fine. Any newly created project is giving this error.
/_ah/api/gateway/v1/invoke?alt=json
no scheduler thread, scheduler.run() will be invoked by report(...) (/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/client.py:235)
Traceback (most recent call last):
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/client.py", line 231, in start
self._thread.start()
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/background_thread/background_thread.py", line 108, in start
start_new_background_thread(self.bootstrap, ())
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/api/background_thread/background_thread.py", line 87, in start_new_background_thread
raise ERROR_MAPerror.application_error
FrontendsNotSupported
.
.
.
(/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263)
Traceback (most recent call last):
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import(cumulative_path)
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/main.py", line 18, in
api = endpoints.api_server([GatewayApi])
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints/apiserving.py", line 514, in api_server
controller)
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/wsgi.py", line 126, in add_all
a_service = loader.load()
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/control/service.py", line 111, in load
return self._load_func(**kw)
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/config/service_config.py", line 79, in fetch_service_config
_log_and_raise(Exception, message_template.format(status_code))
File "/base/data/home/apps/s~ixp-test/20171013t215957.404774686885375478/server/lib/endpoints_management/config/service_config.py", line 127, in _log_and_raise
raise exception_class(message)
Exception: Fetching service config failed (status code 403)
Below is the relevant config
app.yaml
runtime: python27
api_version: 1
threadsafe: false
automatic_scaling:
max_idle_instances: 0
env_variables:
ENDPOINTS_SERVICE_NAME: ixp-test.appspot.com
ENDPOINTS_SERVICE_VERSION: 2017-08-13r0
API
#endpoints.api(name='gateway', version='v1')
class GatewayApi(remote.Service):
#endpoints.method(
GatewayRequest,
GatewayResponse,
path='invoke',
http_method='POST',
name='invoke')
def invoke(self, request):
pass
#endpoints.method(
GatewayRequest,
GatewayResponse,
path='invokeSecure',
http_method='POST',
name='invokeSecure',
scopes=[endpoints.EMAIL_SCOPE])
def invoke_secure(self, request):
pass
This might well happen if the service name in the gatewayv1openapi.json doesn't match the service name in the app.yaml; can you double-check that?
Managed to resolve it. Issue was due to not updating
ENDPOINTS_SERVICE_VERSION: 2017-08-13r0
for new project. Value from old deployed project for which it was working caused the error.
from getting started tutorial
gcloud service-management deploy echov1openapi.json
Service Configuration [2017-02-13-r2] uploaded for service [example-project.appspot.com]
After updating to GAE 1.8.8 and the GCS Client to r127 my code that displays images no longer works using the Development Server or Production. Code that worked previously now throughs the following error in development:
Blob with key 'encoded_gs_file:blahblahblah' does not exist
Note blahblahblah is just my shorthand for a long string.
Below is how I generate my url. This has always worked in the past.
bkey = blobstore.create_gs_key('/gs/mybucket/myfile.jpg')
url = images.get_serving_url(bkey, size=170, crop=True, secure_url=True)
Below is a stack trace from the development server:
ERROR 2013-11-21 20:35:31,767 images_stub.py:405] Blob with key 'encoded_gs_file:c2l0ZS1hdWRpdC1waW5uYWNsZWNyZS9CYXR0ZXJ5L3Bob3Rvcy8yMDEzMTEyMTAwMTEyOUBhNzllYmQwNC05YWY3LTRhMWItYTg3My1mZGIwYjI5MjNjNzguanBn' does not exist
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/images/images_stub.py", line 401, in _OpenBlob
blobstore_stub.BlobstoreServiceStub.ToDatastoreBlobKey(blob_key))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore.py", line 651, in Get
return GetAsync(keys, **kwargs).get_result()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 612, in get_result
return self.__get_result_hook(self)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/datastore/datastore_rpc.py", line 1541, in __get_hook
entities = extra_hook(entities)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/datastore.py", line 620, in local_extra_hook
raise datastore_errors.EntityNotFoundError()
EntityNotFoundError
ApplicationError(1,)
Reading the release notes for GAE 1.8.8 I cannot see anything else I need to change in my code. Any pointers as to what I am doing wrong would be great.
I have been experimenting with Trigger.io and was successfully using it last week.
However, I have been trying new stuff out today, and have been unable to open the Trigger Toolkit properly. I'm not sure why - maybe I deleted something by accident.
The error returned was as follows:
Error in remote call to app.list: Expecting property name: line 25 column 2 (char 482) Details Close
Traceback (most recent call last):
File "/Users/josholdham/Library/Trigger Toolkit/build-tools/forge/async.py", line 96, in run
result = self._target(*self._args, **self._kwargs)
File "/Users/josholdham/Library/Trigger Toolkit/trigger/api/app.py", line 24, in list
return forge_tool.singleton.list_local_apps()
File "/Users/josholdham/Library/Trigger Toolkit/trigger/forge_tool.py", line 175, in list_local_apps
app_config = self._app_config_for_path(path)
File "/Users/josholdham/Library/Trigger Toolkit/trigger/forge_tool.py", line 147, in _app_config_for_path
app_config = json.load(app_config_file)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 278, in load
**kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 326, in loads
return _default_decoder.decode(s)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
def raw_decode(self, s, idx=0):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
ValueError: Expecting property name: line 25 column 2 (char 482)
I have tried uninstalling and reinstalling the toolkit a few times, but no joy.
Any help/ advice much appreciated.
Thanks
Josh
So I figured this out, I was being a bit stupid:
I had to access hidden files on my Mac to find the Users/josholdham/Library/Trigger Toolkit folder, which I then deleted.
Launching Toolkit again then worked fine.
This is how we find hidden files on the Mac, in case it isn't clear.
http://www.mikesel.info/show-hidden-files-mac-os-x-10-7-lion/
Hope that helps some people - thanks to all previous helpers for guidance.
That looks like src/config.json is malformed in one of your apps.
I'd recommend looking at src/config.json in your apps' directories and checking the JSON syntax around line 25.
In the future, you can avoid these problems by using the App Config tab in the Toolkit to change the config, rather than editing src/config.json directly.
I'm getting this error... "ImportError: Could not find 'input_readers' on path 'map reduce'" when trying to Run my map reduce job via the http://localhost:8080/mapreduce launcher page.
It looks like my problem is similar to this post, AppEngine mapper API import error. Unfortunately, no definitive answers were given.
I've simplified it down to this tiny testmapreduce.py:
from google.appengine.ext import db
class TestEntity(db.Model):
value = db.StringProperty()
def mapperhandler(test):
print test.value
return
And my mapreduce.yaml:
mapreduce:
- name: Simplest MapReduce
mapper:
handler: testmapreduce.mapperhandler
input_reader: mapreduce.input_readers.DatastoreInputReader
params:
- name: entity_kind
default: testmapreduce.TestEntity
One possible clue is the presence of __init__.py has no effect (whether in the project root, the mapreduce directory, or both). I'm sure I'm making a beginner mistake, but over the last couple of days I have read every bit of documentation, and all the examples I can find. Thanks.
UPDATE:
I get the same error trying to invoke it via...
control.start_map(
"Give awards",
"testmapreduce.mapperhandler",
"mapreduce.input_readers.DatastoreInputReader",
{"entity_kind": "testmapreduce.TestEntity"},
shard_count=10)
UPDATE:
As requested, the stack trace -- let me know what else would be helpful...
ERROR 2011-10-16 17:09:27,216 _webapp25.py:464] Could not find 'input_readers' on path 'mapreduce'
Traceback (most recent call last):
File "/Develop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/Users/lc/PycharmProjects/mrtest/testmapreduce.py", line 22, in get
shard_count=10) # handle web form test interface
File "/Users/lc/PycharmProjects/mrtest/mapreduce/control.py", line 94, in start_map
transactional=transactional)
File "/Users/lc/PycharmProjects/mrtest/mapreduce/handlers.py", line 811, in _start_map
mapper_input_reader_class = mapper_spec.input_reader_class()
File "/Users/lc/PycharmProjects/mrtest/mapreduce/model.py", line 393, in input_reader_class
return util.for_name(self.input_reader_spec)
File "/Users/lc/PycharmProjects/mrtest/mapreduce/util.py", line 94, in for_name
module = for_name(module_name, recursive=True)
File "/Users/lc/PycharmProjects/mrtest/mapreduce/util.py", line 102, in for_name
short_name, module_name))
ImportError: Could not find 'input_readers' on path 'mapreduce'
INFO 2011-10-16 22:09:27,253 dev_appserver.py:4247] "GET /giveawards HTTP/1.1" 500 -
This problem turned out to be that I was using the 2.7 version of the Python Interpreter in my local environment. When I switched to 2.5, it works fine.