can t run a local httplistener on azure casablanca

Sep 16, 2014 at 11:37 AM

I have created an azure Casablanca application on visual 2010. And I connect to the localhost through the port 8080 to test it by writing "Hello world". The problem is that I have this
Starting Up
Loading C:\Users\EMWorks\documents\visual studio 2010\Projects\CasablancaService
Enter 'quit' or Ctrl-C to terminate...
##### Shutting Down #####

do you have any suggestion please,

Sep 16, 2014 at 7:02 PM
Hi Smarzuki,

We no longer support Visual Studio 2010 -- please make sure you're using the latest version of Casablanca (2.2.0 as of this post). You will need either Visual Studio 2012 or Visual Studio 2013.

Once that's taken care of, I have a shot-in-the-dark possibility for why this doesn't work. I suspect you're waiting on user input to end the program (indicated by the 'quit' to terminate). In an azure worker role, I believe you don't have direct terminal access to the program, which means it will be immediately killed. Try removing the "wait until quit" functionality and just make it loop forever (some sort of sleep loop perhaps).

If this doesn't solve your problem, please post the complete source code (preferably a single file).

Sep 17, 2014 at 9:26 AM
Edited Sep 17, 2014 at 9:26 AM
Hi Roschuma,

I Installed vs 2012 and I have verified that I have the latest version of Azure Casablanca. I open the vs as administrator and here is my code:
// Initialization and Shutdown of CasablancaService2.dll.

#include "stdafx.h"
#include <http_listener.h>

using namespace http;
using namespace http::listener;

http_listener g_listener;

// Function to help find dynamically assigned port for our endpoint.
casablanca::string_t find_addr(const std::vector<casablanca::string_t> &configs)
    // The configuration data is a vector of [key1,value1,key2,value2,...,keyN,valueN] pairs.
    return U("");

bool on_initialize(const std::vector<casablanca::string_t> &args, const std::vector<casablanca::string_t> &configs)
    // TODO: Implement on_initialize. This will be called by Casablanca when CasablancaService2.dll is loaded.
    // Often this will include things like creating an http_listener or hosting/spawning actors.
    // 'args' contains any command line arguments, which can only be specified when running locally not in Azure.
    // 'configs' contains any settings from actors_config.cfg and the port numbers for each Azure endpoint. 

    // As example here is a basic http_listener to get you going.
    g_listener = http_listener::create(find_addr(configs));

    // Associate request handlers with each of the four main HTTP request methods.

    // GET
//  try
//  {
    g_listener = http_listener::create(U("http://localhost:8181"));

    // Provide the listener with a lambda that gets called when the HTTP GET method is received
    // The lambda does not close over any instance or local variables, so is effectively a free-standing static method, [](http_request message)
        message.reply(http::status_codes::OK, U("Hello World!"));
        actors::log::post(actors::LOG_INFO, U("Serviced a GET request for ") + message.request_uri().to_string());

//     }
//     catch (std::exception &e) {
//  return 0;
//  }

    return == 0;

bool on_shutdown()
    // TODO: Implement on_shutdown. This will be called by Casablanca when CasablancaService2.dll is unloaded.
    return g_listener.close() == 0;
Thank you