Get RemotingError when using GAE with PyAMF

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Get RemotingError when using GAE with PyAMF

workie
This post was updated on .
I copied and pasted the sample code from here:
http://pyamf.org/tutorials/gateways/appengine.html?version=91

Even when using the simplest HelloWorld example, the client shows:
pyamf.remoting.RemotingError: Incorrect MIME type received. (got: None)

* Later on I tried the alternate method using WSGIGateway instead of WebAppGateway and that worked.


Server Code:
import logging
import wsgiref.handlers

from google.appengine.ext import webapp

from pyamf.remoting.gateway.google import WebAppGateway

class MainPage(webapp.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')


def echo(data):
    print "Lisa's echo function is called"
    return data

def hello():
    print "Lisa's hello function is called"
    return


services = {
    'myservice.echo': echo,
    'myservice.hello': hello
}


def main():
    print "Lisa's main function is called"
    gateway = WebAppGateway(services, logger=logging, debug=True, expose_request=False)
    application_paths = [('/', gateway), ('/helloworld', MainPage)]
    application = webapp.WSGIApplication(application_paths, debug=True)

    wsgiref.handlers.CGIHandler().run(application)

Client Code:
import logging

from pyamf.remoting.client import RemotingService

   
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
)


path = 'http://localhost:8083/'
gw = RemotingService(path, logger=logging)
service = gw.getService('myservice')

service.hello()
print "done with hello"


Server Output:
INFO     2010-02-10 21:24:46,760 appengine_rpc.py:157] Server: appengine.google.
com
INFO     2010-02-10 21:24:46,769 appcfg.py:348] Checking for updates to the SDK.

DEBUG    2010-02-10 21:24:46,772 appengine_rpc.py:343] Sending HTTP request:
POST /api/updatecheck?release=1.3.0×tamp=1259695715&api_versions=%5B%271%27
%5D HTTPS/1.1
Host: appengine.google.com
X-appcfg-api-version: 1
Content-type: application/octet-stream
User-agent: appcfg_py/1.3.0 win32/6.0.6000.2 Python/2.5.4.final.0


INFO     2010-02-10 21:24:47,990 appcfg.py:362] The SDK is up to date.
WARNING  2010-02-10 21:24:48,036 dev_appserver.py:3578] Could not initialize ima
ges API; you are likely missing the Python "PIL" module. ImportError: No module
named _imaging
INFO     2010-02-10 21:24:48,045 dev_appserver_main.py:399] Running application
mygae on port 8083: http://localhost:8083
DEBUG    2010-02-10 21:24:52,532 dev_appserver.py:488] Matched "/" to CGI dispat
cher with path helloworld.py
DEBUG    2010-02-10 21:24:52,535 dev_appserver.py:2287] Executing CGI with env:
{'APPLICATION_ID': 'mygae',
 'AUTH_DOMAIN': 'gmail.com',
 'CONTENT_LENGTH': '36',
 'CONTENT_TYPE': 'application/x-amf',
 'CURRENT_VERSION_ID': '1.1',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_HOST': 'localhost:8083',
 'HTTP_USER_AGENT': 'PyAMF/0.5.1',
 'PATH_INFO': '/',
 'PATH_TRANSLATED': 'C:\\gae\\mygae\\src\\helloworld.py',
 'QUERY_STRING': '',
 'REMOTE_ADDR': '127.0.0.1',
 'REQUEST_METHOD': 'POST',
 'SCRIPT_NAME': '',
 'SERVER_NAME': 'localhost',
 'SERVER_PORT': '8083',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SOFTWARE': 'Development/1.0',
 'TZ': 'UTC',
 'USER_EMAIL': '',
 'USER_ID': '',
 'USER_ORGANIZATION': ''}
INFO     2010-02-10 21:24:53,664 dev_appserver.py:3243] "POST / HTTP/1.1" 200 -
INFO     2010-02-10 21:24:53,676 dev_appserver_index.py:205] Updating C:\gae\myg
ae\src\index.yaml

Client Output:
2010-02-10 16:24:51,490 INFO  [root] Connecting to http://localhost:8083/
2010-02-10 16:24:51,490 DEBUG [root] Referer: None
2010-02-10 16:24:51,490 DEBUG [root] User-Agent: PyAMF/0.5.1
2010-02-10 16:24:51,490 DEBUG [root] Adding request myservice.hello()
2010-02-10 16:24:51,490 DEBUG [root] Executing single request: /1
2010-02-10 16:24:51,490 DEBUG [root] AMF version: 0
2010-02-10 16:24:51,492 DEBUG [root] Client type: 0
2010-02-10 16:24:51,499 DEBUG [root] Sending POST request to /
2010-02-10 16:24:52,520 DEBUG [root] Waiting for response...
2010-02-10 16:24:53,667 DEBUG [root] Got response status: 200
2010-02-10 16:24:53,667 DEBUG [root] Content-Type: None
2010-02-10 16:24:53,667 DEBUG [root] Body =
Traceback (most recent call last):
  File "test_client.py", line 16, in <module>
    service.hello()
  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 55, in __call_
_
    return self.service._call(self, *args)
  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 105, in _call
    response = self._gw.execute_single(request)
  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 424, in execut
e_single
    envelope = self._getResponse()
  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 487, in _getRe
sponse
    raise remoting.RemotingError("Incorrect MIME type received. (got: %s)" % con
tent_type)
pyamf.remoting.RemotingError: Incorrect MIME type received. (got: None)

Reply | Threaded
Open this post in threaded view
|

Re: Get RemotingError when using GAE with PyAMF

Nick Joyce
Hi Lisa,

Google takes output to stdout and adds it as part of the response, so the print statements within the code *appear* to be screwing with the response.

If you switch those out for logging statements, you should get better mileage.

Let me know if this helps, WebAppGateway has plenty of unittest coverage but little real world exposure.

Thanks!

Nick


On 11 Feb 2010, at 18:33, workie wrote:

>
> I copied and pasted the sample code from here:
> http://pyamf.org/tutorials/gateways/appengine.html?version=91
>
> Even when using the simplest HelloWorld example, the client shows:
> pyamf.remoting.RemotingError: Incorrect MIME type received. (got: None)
>
> * Later on I tried the alternate method using WSGIGateway instead of
> WebAppGateway and that worked.
>
>
> Server Code:
> import logging
> import wsgiref.handlers
>
> from google.appengine.ext import webapp
>
> from pyamf.remoting.gateway.google import WebAppGateway
>
> class MainPage(webapp.RequestHandler):
>    def get(self):
>        self.response.headers['Content-Type'] = 'text/plain'
>        self.response.out.write('Hello, webapp World!')
>
>
> def echo(data):
>    print "Lisa's echo function is called"
>    return data
>
> def hello():
>    print "Lisa's hello function is called"
>    return
>
>
> services = {
>    'myservice.echo': echo,
>    'myservice.hello': hello
> }
>
>
> def main():
>    print "Lisa's main function is called"
>    gateway = WebAppGateway(services, logger=logging, debug=True,
> expose_request=False)
>    application_paths = [('/', gateway), ('/helloworld', MainPage)]
>    application = webapp.WSGIApplication(application_paths, debug=True)
>
>    wsgiref.handlers.CGIHandler().run(application)
>
> Client Code:
> import logging
>
> from pyamf.remoting.client import RemotingService
>
>
> logging.basicConfig(
>    level=logging.DEBUG,
>    format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
> )
>
>
> path = 'http://localhost:8083/'
> gw = RemotingService(path, logger=logging)
> service = gw.getService('myservice')
>
> service.hello()
> print "done with hello"
>
>
> Server Output:
> INFO     2010-02-10 21:24:46,760 appengine_rpc.py:157] Server:
> appengine.google.
> com
> INFO     2010-02-10 21:24:46,769 appcfg.py:348] Checking for updates to the
> SDK.
>
> DEBUG    2010-02-10 21:24:46,772 appengine_rpc.py:343] Sending HTTP request:
> POST
> /api/updatecheck?release=1.3.0&timestamp=1259695715&api_versions=%5B%271%27
> %5D HTTPS/1.1
> Host: appengine.google.com
> X-appcfg-api-version: 1
> Content-type: application/octet-stream
> User-agent: appcfg_py/1.3.0 win32/6.0.6000.2 Python/2.5.4.final.0
>
>
> INFO     2010-02-10 21:24:47,990 appcfg.py:362] The SDK is up to date.
> WARNING  2010-02-10 21:24:48,036 dev_appserver.py:3578] Could not initialize
> ima
> ges API; you are likely missing the Python "PIL" module. ImportError: No
> module
> named _imaging
> INFO     2010-02-10 21:24:48,045 dev_appserver_main.py:399] Running
> application
> mygae on port 8083: http://localhost:8083
> DEBUG    2010-02-10 21:24:52,532 dev_appserver.py:488] Matched "/" to CGI
> dispat
> cher with path helloworld.py
> DEBUG    2010-02-10 21:24:52,535 dev_appserver.py:2287] Executing CGI with
> env:
> {'APPLICATION_ID': 'mygae',
> 'AUTH_DOMAIN': 'gmail.com',
> 'CONTENT_LENGTH': '36',
> 'CONTENT_TYPE': 'application/x-amf',
> 'CURRENT_VERSION_ID': '1.1',
> 'GATEWAY_INTERFACE': 'CGI/1.1',
> 'HTTP_HOST': 'localhost:8083',
> 'HTTP_USER_AGENT': 'PyAMF/0.5.1',
> 'PATH_INFO': '/',
> 'PATH_TRANSLATED': 'C:\\gae\\mygae\\src\\helloworld.py',
> 'QUERY_STRING': '',
> 'REMOTE_ADDR': '127.0.0.1',
> 'REQUEST_METHOD': 'POST',
> 'SCRIPT_NAME': '',
> 'SERVER_NAME': 'localhost',
> 'SERVER_PORT': '8083',
> 'SERVER_PROTOCOL': 'HTTP/1.0',
> 'SERVER_SOFTWARE': 'Development/1.0',
> 'TZ': 'UTC',
> 'USER_EMAIL': '',
> 'USER_ID': '',
> 'USER_ORGANIZATION': ''}
> INFO     2010-02-10 21:24:53,664 dev_appserver.py:3243] "POST / HTTP/1.1"
> 200 -
> INFO     2010-02-10 21:24:53,676 dev_appserver_index.py:205] Updating
> C:\gae\myg
> ae\src\index.yaml
>
> Client Output:
> 2010-02-10 16:24:51,490 INFO  [root] Connecting to http://localhost:8083/
> 2010-02-10 16:24:51,490 DEBUG [root] Referer: None
> 2010-02-10 16:24:51,490 DEBUG [root] User-Agent: PyAMF/0.5.1
> 2010-02-10 16:24:51,490 DEBUG [root] Adding request myservice.hello()
> 2010-02-10 16:24:51,490 DEBUG [root] Executing single request: /1
> 2010-02-10 16:24:51,490 DEBUG [root] AMF version: 0
> 2010-02-10 16:24:51,492 DEBUG [root] Client type: 0
> 2010-02-10 16:24:51,499 DEBUG [root] Sending POST request to /
> 2010-02-10 16:24:52,520 DEBUG [root] Waiting for response...
> 2010-02-10 16:24:53,667 DEBUG [root] Got response status: 200
> 2010-02-10 16:24:53,667 DEBUG [root] Content-Type: None
> 2010-02-10 16:24:53,667 DEBUG [root] Body =
> Traceback (most recent call last):
>  File "test_client.py", line 16, in <module>
>    service.hello()
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 55, in
> __call_
> _
>    return self.service._call(self, *args)
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 105, in
> _call
>    response = self._gw.execute_single(request)
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 424, in
> execut
> e_single
>    envelope = self._getResponse()
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 487, in
> _getRe
> sponse
>    raise remoting.RemotingError("Incorrect MIME type received. (got: %s)" %
> con
> tent_type)
> pyamf.remoting.RemotingError: Incorrect MIME type received. (got: None)
>
>
> --
> View this message in context: http://old.nabble.com/Get-RemotingError-when-using-GAE-with-PyAMF-tp27538432p27538432.html
> Sent from the pyamf-users mailing list archive at Nabble.com.
>
> _______________________________________________
> PyAMF users mailing list - [hidden email]
> http://lists.pyamf.org/mailman/listinfo/users

_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Get RemotingError when using GAE with PyAMF

workie

Nick Joyce wrote
Hi Lisa,

Google takes output to stdout and adds it as part of the response, so the print statements within the code *appear* to be screwing with the response.

If you switch those out for logging statements, you should get better mileage.

Let me know if this helps, WebAppGateway has plenty of unittest coverage but little real world exposure.

Thanks!

Nick


On 11 Feb 2010, at 18:33, workie wrote:

>
> I copied and pasted the sample code from here:
> http://pyamf.org/tutorials/gateways/appengine.html?version=91
>
> Even when using the simplest HelloWorld example, the client shows:
> pyamf.remoting.RemotingError: Incorrect MIME type received. (got: None)
>
> * Later on I tried the alternate method using WSGIGateway instead of
> WebAppGateway and that worked.
>
>
> Server Code:
> import logging
> import wsgiref.handlers
>
> from google.appengine.ext import webapp
>
> from pyamf.remoting.gateway.google import WebAppGateway
>
> class MainPage(webapp.RequestHandler):
>    def get(self):
>        self.response.headers['Content-Type'] = 'text/plain'
>        self.response.out.write('Hello, webapp World!')
>
>
> def echo(data):
>    print "Lisa's echo function is called"
>    return data
>
> def hello():
>    print "Lisa's hello function is called"
>    return
>
>
> services = {
>    'myservice.echo': echo,
>    'myservice.hello': hello
> }
>
>
> def main():
>    print "Lisa's main function is called"
>    gateway = WebAppGateway(services, logger=logging, debug=True,
> expose_request=False)
>    application_paths = [('/', gateway), ('/helloworld', MainPage)]
>    application = webapp.WSGIApplication(application_paths, debug=True)
>
>    wsgiref.handlers.CGIHandler().run(application)
>
> Client Code:
> import logging
>
> from pyamf.remoting.client import RemotingService
>
>
> logging.basicConfig(
>    level=logging.DEBUG,
>    format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
> )
>
>
> path = 'http://localhost:8083/'
> gw = RemotingService(path, logger=logging)
> service = gw.getService('myservice')
>
> service.hello()
> print "done with hello"
>
>
> Server Output:
> INFO     2010-02-10 21:24:46,760 appengine_rpc.py:157] Server:
> appengine.google.
> com
> INFO     2010-02-10 21:24:46,769 appcfg.py:348] Checking for updates to the
> SDK.
>
> DEBUG    2010-02-10 21:24:46,772 appengine_rpc.py:343] Sending HTTP request:
> POST
> /api/updatecheck?release=1.3.0×tamp=1259695715&api_versions=%5B%271%27
> %5D HTTPS/1.1
> Host: appengine.google.com
> X-appcfg-api-version: 1
> Content-type: application/octet-stream
> User-agent: appcfg_py/1.3.0 win32/6.0.6000.2 Python/2.5.4.final.0
>
>
> INFO     2010-02-10 21:24:47,990 appcfg.py:362] The SDK is up to date.
> WARNING  2010-02-10 21:24:48,036 dev_appserver.py:3578] Could not initialize
> ima
> ges API; you are likely missing the Python "PIL" module. ImportError: No
> module
> named _imaging
> INFO     2010-02-10 21:24:48,045 dev_appserver_main.py:399] Running
> application
> mygae on port 8083: http://localhost:8083
> DEBUG    2010-02-10 21:24:52,532 dev_appserver.py:488] Matched "/" to CGI
> dispat
> cher with path helloworld.py
> DEBUG    2010-02-10 21:24:52,535 dev_appserver.py:2287] Executing CGI with
> env:
> {'APPLICATION_ID': 'mygae',
> 'AUTH_DOMAIN': 'gmail.com',
> 'CONTENT_LENGTH': '36',
> 'CONTENT_TYPE': 'application/x-amf',
> 'CURRENT_VERSION_ID': '1.1',
> 'GATEWAY_INTERFACE': 'CGI/1.1',
> 'HTTP_HOST': 'localhost:8083',
> 'HTTP_USER_AGENT': 'PyAMF/0.5.1',
> 'PATH_INFO': '/',
> 'PATH_TRANSLATED': 'C:\\gae\\mygae\\src\\helloworld.py',
> 'QUERY_STRING': '',
> 'REMOTE_ADDR': '127.0.0.1',
> 'REQUEST_METHOD': 'POST',
> 'SCRIPT_NAME': '',
> 'SERVER_NAME': 'localhost',
> 'SERVER_PORT': '8083',
> 'SERVER_PROTOCOL': 'HTTP/1.0',
> 'SERVER_SOFTWARE': 'Development/1.0',
> 'TZ': 'UTC',
> 'USER_EMAIL': '',
> 'USER_ID': '',
> 'USER_ORGANIZATION': ''}
> INFO     2010-02-10 21:24:53,664 dev_appserver.py:3243] "POST / HTTP/1.1"
> 200 -
> INFO     2010-02-10 21:24:53,676 dev_appserver_index.py:205] Updating
> C:\gae\myg
> ae\src\index.yaml
>
> Client Output:
> 2010-02-10 16:24:51,490 INFO  [root] Connecting to http://localhost:8083/
> 2010-02-10 16:24:51,490 DEBUG [root] Referer: None
> 2010-02-10 16:24:51,490 DEBUG [root] User-Agent: PyAMF/0.5.1
> 2010-02-10 16:24:51,490 DEBUG [root] Adding request myservice.hello()
> 2010-02-10 16:24:51,490 DEBUG [root] Executing single request: /1
> 2010-02-10 16:24:51,490 DEBUG [root] AMF version: 0
> 2010-02-10 16:24:51,492 DEBUG [root] Client type: 0
> 2010-02-10 16:24:51,499 DEBUG [root] Sending POST request to /
> 2010-02-10 16:24:52,520 DEBUG [root] Waiting for response...
> 2010-02-10 16:24:53,667 DEBUG [root] Got response status: 200
> 2010-02-10 16:24:53,667 DEBUG [root] Content-Type: None
> 2010-02-10 16:24:53,667 DEBUG [root] Body =
> Traceback (most recent call last):
>  File "test_client.py", line 16, in <module>
>    service.hello()
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 55, in
> __call_
> _
>    return self.service._call(self, *args)
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 105, in
> _call
>    response = self._gw.execute_single(request)
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 424, in
> execut
> e_single
>    envelope = self._getResponse()
>  File "C:\gae\mygae\src\pyamf\remoting\client\__init__.py", line 487, in
> _getRe
> sponse
>    raise remoting.RemotingError("Incorrect MIME type received. (got: %s)" %
> con
> tent_type)
> pyamf.remoting.RemotingError: Incorrect MIME type received. (got: None)
>
>
> --
> View this message in context: http://old.nabble.com/Get-RemotingError-when-using-GAE-with-PyAMF-tp27538432p27538432.html
> Sent from the pyamf-users mailing list archive at Nabble.com.
>
> _______________________________________________
> PyAMF users mailing list - users@pyamf.org
> http://lists.pyamf.org/mailman/listinfo/users

_______________________________________________
PyAMF users mailing list - users@pyamf.org
http://lists.pyamf.org/mailman/listinfo/users
oops - thanks.  Got it working.