0

I'm using python and cloud9 trying to setup a simple XMLRPC server. If I run this all on my local host, I have no issues. On the Cloud9 host, I get get a ProtocolError 302 Moved temporarily.

Any ideas?

The server code is:

from SimpleXMLRPCServer import SimpleXMLRPCServer
import logging
import os

ip = os.getenv("IP", "0.0.0.0")
port = int(os.getenv("PORT", 8080))

logging.basicConfig(level=logging.DEBUG)

server = SimpleXMLRPCServer((ip, port), logRequests=True)

def list_contents(dir_name):
    logging.debug('list_contents(%s)', dir_name)
    return dir_name
server.register_function(list_contents)

try:
    print 'Use Control-C to exit'
    server.serve_forever()
except KeyboardInterrupt:
    print 'Exiting'

The client code is:

import xmlrpclib

url = "https://xxxxx.c9.io/"
srv = xmlrpclib.ServerProxy(url, verbose=True)
print srv.list_contents("asdf")
mikeb
  • 10,578
  • 7
  • 62
  • 120

1 Answers1

4

The 302 response is most likely redirecting you to an authentication/authorisation URL to assess your permissions to access the application. This is always the response if you configured your workspace / access via web to be private (no unauthenticated access).

You can either share it publicly (click Share -> click 'application' to be public) or provide username and password in the requested URL in the client:

url = "https://username:password@workspace-c9-user.c9.io/" 
basdw
  • 486
  • 2
  • 1
  • this could make sense, but I'm experiencing the same issue as well. This doesn't always happen (like a login page...), but after navigating in my app during a few minutes, I get this error. Reloading the app (F5 / cmd+r) is enough to get rid off the error... for the next few minutes. The redirection URL (https://c9.io/api/nc/auth?response_type=token&client_id=user.content.c9.legacy....) hints also to an authentication issue, but it's quite interesting why it works during a few minutes and then suddenly fail ... ?? – Christophe Vidal Oct 26 '15 at 14:49