@@ -39,6 +39,8 @@ class Client
3939 public static $ subdomains = [];
4040 public static $ localUrl = '' ;
4141
42+ protected ?string $ closingMessage = null ;
43+
4244 public function __construct (LoopInterface $ loop , Configuration $ configuration , CliLogger $ logger )
4345 {
4446 $ this ->loop = $ loop ;
@@ -113,6 +115,10 @@ public function connectToServer(string $sharedUrl, $subdomain, $serverHost = nul
113115 $ connection ->authenticate ($ sharedUrl , $ subdomain , $ serverHost );
114116
115117 $ clientConnection ->on ('close ' , function () use ($ sharedUrl , $ subdomain , $ serverHost , $ authToken ) {
118+ if ($ this ->closingMessage ) {
119+ $ this ->logger ->renderMessage ($ this ->closingMessage );
120+ }
121+
116122 $ this ->logger ->error ('Connection to server closed. ' );
117123
118124 $ this ->retryConnectionOrExit (function () use ($ sharedUrl , $ subdomain , $ serverHost , $ authToken ) {
@@ -139,6 +145,8 @@ public function connectToServer(string $sharedUrl, $subdomain, $serverHost = nul
139145 $ this ->logger ->renderMessage ($ data ->message );
140146 }
141147
148+ $ this ->closingMessage = $ data ->closing_message ?? null ;
149+
142150 $ this ->logger ->renderConnectionTable ([
143151 "Shared site " => $ sharedUrl ,
144152 "Dashboard " => "http://127.0.0.1: " .config ()->get ('expose.dashboard_port ' ),
@@ -189,6 +197,10 @@ public function connectToServerAndShareTcp(int $port, $authToken = ''): PromiseI
189197 $ this ->attachCommonConnectionListeners ($ connection , $ deferred );
190198
191199 $ clientConnection ->on ('close ' , function () use ($ port , $ authToken ) {
200+ if ($ this ->closingMessage ) {
201+ $ this ->logger ->renderMessage ($ this ->closingMessage );
202+ }
203+
192204 $ this ->logger ->error ('Connection to server closed. ' );
193205
194206 $ this ->retryConnectionOrExit (function () use ($ port , $ authToken ) {
@@ -205,6 +217,8 @@ public function connectToServerAndShareTcp(int $port, $authToken = ''): PromiseI
205217 $ this ->logger ->info ("Expose-URL: \t\t<options=bold>tcp:// {$ host }: {$ data ->shared_port }</> " );
206218 $ this ->logger ->line ('' );
207219
220+ $ this ->closingMessage = $ data ->closing_message ?? null ;
221+
208222 $ deferred ->resolve ($ data );
209223 });
210224 }, function (\Exception $ e ) use ($ deferred , $ port , $ authToken ) {
0 commit comments