I-Azure Service Bus ye-Node.js: i-HTTP proxy nge-AMQP phezu kwe-WebSockets
Lungisa i-@azure/service-bus nge-ws ne-HttpsProxyAgent lapho ukuxhumana kwe-AMQP kufanele kudlule i-HTTP proxy.
Kumakhasimende emilayezo we-Service Bus v7 we-Node ngemva kwe-HTTP proxy, sebenzisa ukuhlelwa kwe-AMQP-over-WebSockets kwesibonelo se-SDK:
const { ServiceBusClient } = require("@azure/service-bus");
const WebSocket = require("ws");
const { HttpsProxyAgent } = require("https-proxy-agent");
const proxyAgent = new HttpsProxyAgent(proxyUrl);
const client = new ServiceBusClient(connectionString, {
webSocketOptions: {
webSocket: WebSocket,
webSocketConstructorOptions: { agent: proxyAgent },
},
});
Nikeza i-URL ye-proxy kanye neyunithi yokuxhumana ye-Service Bus. Ukuze kuvivinywe i-namespace yomphakathi ye-Service Bus evunyelwe ngaphandle kokuqinisekiswa kwe-proxy, umbhalo we-HTTP ovela kuhlu lwama-proxy e-HTTP ungahlinzeka nge-proxyUrl. Amaphakethe e-ws ne-https-proxy-agent kufanele abe yizinto ezincike kuzo zohlelo lokusebenza. Isixhumanisi esiyisisekelo se-ws proxy-agent sigcina isevisi ye-WebSocket namakheli e-proxy ehlukene.
Lokhu kwakha iklayenti; ukuxhumana kwenzeka lapho umthumeli noma umamukeli enza umsebenzi. Kugcinele lowo mthwalo womsebenzi futhi ulinde client.close() lapho uvala.
Thola ukwehluleka phakathi kokusethwa komhubhe we-proxy, ukuxoxisana kwe-WebSocket nomsebenzi we-Service Bus. I-proxy kufanele ivume leyo ndawo naleso sikhathi. Ukufinyelela okufushane kwe-HTTPS akufakazeli ukusekelwa kokuthuthukiswa noma umkhawulo owamukelekayo wokuxhumana kwesikhathi eside.
Lokhu ukugcwala kweyunithi yokuxhumana. Isiqinisekiso sobunikazi singangeza indlela ehlelwe ngokwehlukile yokuthola ithokheni. Izingcezu zakudala ze-REST ze-azure-sb zisebenzisa esinye isizukulwane; khomba iphakethe ngaphambi kokukhetha izinketho zalo zokuthutha.