Skip to content

network error when deployed on Amazon ECS #58

@NiharikaPatel

Description

@NiharikaPatel

Bukdu seems to be working fine when locally deployed on a docker container, however, it does not seem to work when pushed to ECS.

This is our code

using Bukdu
using HTTP.Messages: setheader
using JSON
using JLD
using Dates

struct SimulationController <: ApplicationController
    conn::Conn
end

function take_options(c::SimulationController)
    req = c.conn.request
    @info :req_headers req.headers
    @info :req_method_target (req.method, req.target)
     setheader(req.response, "Access-Control-Allow-Headers" => (
        "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept"
    ))
     setheader(req.response, "Access-Control-Allow-Origin" => "*")
     setheader(req.response,"Access-Control-Allow-Methods" => "POST, GET, PUT, DELETE, OPTIONS")
     setheader(req.response,"Access-Control-Allow-Credentials" => "false")
     setheader(req.response,"Access-Control-Max-Age" => "86400")
    nothing
end

function run_simulation(inputs_string::String)
    timestamp = now()
    @info :inputs inputs_string
    #work
    output = "Hello World"
    return output
end

function get_http_handler(c::SimulationController)
    # inputs_string = String(c.conn.request.body)
    # println(c.conn.request.target)
    req = c.conn.request
    @info req.target
    @info req.method
    input_string = String(req.body)
    if req.target == "/run" && req.method == "POST"
        output = run_simulation(input_string))
    else
        output = "Not found"
    end
    setheader(req.response, "Access-Control-Allow-Origin" => "*")
    render(JSON, output)
end

routes() do
    Bukdu.options("/", SimulationController, take_options)
    Bukdu.options("/run", SimulationController, take_options)
end

Bukdu.start(8080,host="0.0.0.0")

Base.JLOptions().isinteractive==0 && wait()

We tested it hosting the client on localhost 8080 and also the client hosted on AWS s3 while the back end was running locally and it worked fine but once we deployed it on AWS ECS, it did not seem to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions