Allow unsecure WebSocket connections

Some setup like ours will have the WebSocket connection in a private
network to a local node and thus do not require a secure connection.
This change allows to specify ws:// instead of wss:// endpoints as well
as reading from the ENV var for the geth config of the indexer

Co-authored-by: Luke Imhoff <luke.imhoff@dockyard.com>
pull/864/head
Nam Chu Hoai 6 years ago committed by Luke Imhoff
parent 855280e4e1
commit d17917ce30
  1. 16
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/web_socket/web_socket_client.ex
  2. 2
      apps/indexer/config/dev/geth.exs

@ -55,6 +55,22 @@ defmodule EthereumJSONRPC.WebSocket.WebSocketClient do
)
end
def start_link(["ws://" <> _ = url, gen_fsm_options]) when is_list(gen_fsm_options) do
fsm_name =
case Keyword.fetch(gen_fsm_options, :name) do
{:ok, name} when is_atom(name) -> {:local, name}
:error -> :undefined
end
:websocket_client.start_link(
fsm_name,
url,
__MODULE__,
url,
[]
)
end
# Client interface
@impl WebSocket

@ -15,6 +15,6 @@ config :indexer,
transport: EthereumJSONRPC.WebSocket,
transport_options: [
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: "wss://mainnet.infura.io/ws/8lTvJTKmHPCHazkneJsY"
url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "wss://mainnet.infura.io/ws/8lTvJTKmHPCHazkneJsY"
]
]

Loading…
Cancel
Save