diff --git a/src/Middleware/TunnelMiddleware.php b/src/Middleware/TunnelMiddleware.php index 3d49b7f..84370fd 100644 --- a/src/Middleware/TunnelMiddleware.php +++ b/src/Middleware/TunnelMiddleware.php @@ -42,7 +42,7 @@ class TunnelMiddleware $content = $response->getOriginalContent(); $status = isset($content['error']) ? $content['error']['code'] : 200; - $client = new \InfluxDB\Client('http://localhost', '8086'); + $client = new \InfluxDB\Client('127.0.0.1', '8086'); $database = $client->selectDB('rpc_monitor'); $points = array( new Point( diff --git a/src/Server/JsonRpcMethod.php b/src/Server/JsonRpcMethod.php index a5ca9ef..e91531a 100644 --- a/src/Server/JsonRpcMethod.php +++ b/src/Server/JsonRpcMethod.php @@ -28,14 +28,24 @@ class JsonRpcMethod extends JsonRpcBase public function error($code, $msg) { - return [ - 'jsonrpc' => '2.0', - 'error' => [ - 'code' => $code, - 'message' => is_array($msg) ? json_encode($msg) : $msg, - ], - 'id' => $this->id - ]; + return is_string($msg) + ? [ + 'jsonrpc' => '2.0', + 'error' => [ + 'code' => $code, + 'message' => $msg, + ], + 'id' => $this->id + ] + : [ + 'jsonrpc' => '2.0', + 'error' => [ + 'code' => $code, + 'message' => self::ErrorMsg[$code], + 'data' => $msg + ], + 'id' => $this->id + ]; } } \ No newline at end of file