fixes from initial load testing

This commit is contained in:
Dave Horton
2020-02-22 15:06:01 -05:00
parent 4bd9e015b5
commit fa05b76451
8 changed files with 108 additions and 67 deletions

View File

@@ -435,7 +435,7 @@ class CallSession extends Emitter {
// need to allocate an endpoint
try {
if (!this.ms) this.ms = await this.getMS();
if (!this.ms) this.ms = this.getMS();
const ep = await this.ms.createEndpoint({remoteSdp: this.req.body});
ep.cs = this;
this.ep = ep;
@@ -485,7 +485,7 @@ class CallSession extends Emitter {
* Hang up the call and free the media endpoint
*/
async _clearResources() {
for (const resource of [this.dlg, this.ep, this.ms]) {
for (const resource of [this.dlg, this.ep]) {
try {
if (resource && resource.connected) await resource.destroy();
} catch (err) {
@@ -505,12 +505,10 @@ class CallSession extends Emitter {
/**
* get a media server to use for this call
*/
async getMS() {
getMS() {
if (!this.ms) {
const fsOpts = this.srf.locals.getFreeswitch();
if (!fsOpts) throw new Error('no available freeswitch');
const mrf = this.srf.locals.mrf;
this.ms = await mrf.connect(fsOpts);
this.ms = this.srf.locals.getFreeswitch();
if (!this.ms) throw new Error('no available freeswitch');
}
return this.ms;
}
@@ -520,14 +518,13 @@ class CallSession extends Emitter {
* the current media server and endpoint that are associated with this call
*/
async createOrRetrieveEpAndMs() {
const mrf = this.srf.locals.mrf;
if (this.ms && this.ep) return {ms: this.ms, ep: this.ep};
// get a media server
if (!this.ms) {
const fsOpts = this.srf.locals.getFreeswitch();
if (!fsOpts) throw new Error('no available freeswitch');
this.ms = await mrf.connect(fsOpts);
const ms = this.srf.locals.getFreeswitch();
if (!ms) throw new Error('no available freeswitch');
this.ms = ms;
}
if (!this.ep) {
this.ep = await this.ms.createEndpoint({remoteSdp: this.req.body});