今天啟動(dòng)GateWay服務(wù)后征程,想GateWay發(fā)送消息后,報(bào)這個(gè)錯(cuò)誤了
------------------------ WORKERMAN -----------------------------
Workerman version:3.3.1 PHP version:5.5.31
------------------------ WORKERS -------------------------------
user worker listen processes status
Debw Gateway websocket://0.0.0.0:13016 1
Debw PushWorker text://127.0.0.1:13002 1
Debw Register text://0.0.0.0:1236 1
Debw TaskWorker text://127.0.0.1:13000 10
Debw TimeWorker text://127.0.0.1:13001 1
Debw TradeBusiness none 1
----------------------------------------------------------------
Press Ctrl-C to quit. Start success.
SendBufferToWorker fail. The connections between Gateway and BusinessWorker are not ready
SendBufferToWorker fail. The connections between Gateway and BusinessWorker are not ready
SendBufferToWorker fail. The connections between Gateway and BusinessWorker are not ready
SendBufferToWorker fail. The connections between Gateway and BusinessWorker are not ready
然后,因?yàn)槲沂荕AC系統(tǒng),我使用sudo dtruss -p 625來看GateWay的進(jìn)程,再發(fā)送一次消息后,然后顯示如下error提示,不知道是哪里出了問題呢?
sudo dtruss -p 625
SYSCALL(args) = return
dtrace: error on enabled probe ID 2067 (ID 328: syscall::select:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2341 (ID 602: syscall::poll:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2541 (ID 202: syscall::accept:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2479 (ID 326: syscall::fcntl:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2479 (ID 326: syscall::fcntl:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2022 (ID 822: syscall::lstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2022 (ID 822: syscall::lstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2022 (ID 822: syscall::lstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2022 (ID 822: syscall::lstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2022 (ID 822: syscall::lstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2022 (ID 822: syscall::lstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2039 (ID 152: syscall::open:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2232 (ID 820: syscall::fstat64:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2372 (ID 540: syscall::lseek:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2372 (ID 540: syscall::lseek:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2440 (ID 404: syscall::flock:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2041 (ID 150: syscall::write:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2053 (ID 154: syscall::close:return): invalid user access in action #5 at DIF offset 0
dtrace: error on enabled probe ID 2053 (ID 154: syscall::close:return): invalid user access in action #5 at DIF offset 0
SendBufferToWorker?fail.?The?connections?between?Gateway?and?BusinessWorker?are?not?ready.
原因
BusinessWorker和Gateway之間的socket鏈接沒有建立,Gateway向BusinessWorker發(fā)送消息失敗。
出現(xiàn)這個(gè)問題的原因一般是start_gateway.php和start_businessworker.php中的
regtisterAddress
設(shè)置錯(cuò)誤或者設(shè)置的不一致。
?
Gateway和BusinessWorker啟動(dòng)后會(huì)根據(jù)
regtisterAddress
設(shè)置的地址(Register服務(wù)地址)注冊(cè)自己,
當(dāng)start_gateway.php和start_businessworker.php中的
regtisterAddress
設(shè)置錯(cuò)誤或者不一致時(shí),
會(huì)導(dǎo)致Gateway和BusinessWorker無法通訊。
?
start_gateway.php和start_businessworker.php中的
regtisterAddress
地址格式為
Register的IP:端口號(hào)
,
其中端口號(hào)為start_register.php中的監(jiān)聽端口(假設(shè)是1238),
單機(jī)部署時(shí),Register服務(wù)為本機(jī)ip 127.0.0.1,則start_gateway.php和start_businessworker.php中的
regtisterAddress
統(tǒng)一為
'127.0.0.1:1238'
。
分布式(集群)部署時(shí),IP為實(shí)際Register服務(wù)部署的IP(分布式部署時(shí)只需要部署一臺(tái)Register服務(wù)即可,假設(shè)是192.168.1.100),
則start_gateway.php和start_businessworker.php中的
regtisterAddress
統(tǒng)一為
'192.168.1.100:1238'
。
?
其它原因
業(yè)務(wù)設(shè)置了business_worker->onWorkerStart 或者 Events::onWorkerStart 回調(diào),并且回調(diào)里有死循環(huán)或者長(zhǎng)時(shí)間阻塞的代碼,致使框架無法執(zhí)行businessWorker與gateway建立連接邏輯,導(dǎo)致報(bào)錯(cuò)。
將死循環(huán)或者長(zhǎng)時(shí)間阻塞的代碼去掉即可恢復(fù)。
@walker 啟動(dòng)沒有問題,只要沒有客戶端鏈接,就不會(huì)有問題,調(diào)試了一下,感覺鏈接握手時(shí)就會(huì)報(bào)這個(gè)錯(cuò)誤,如果不再連了,就沒有這個(gè)錯(cuò)誤。 現(xiàn)在不知該去哪個(gè)地方調(diào)試?