Coder Social home page Coder Social logo

zhouhailin / freeswitch-externals Goto Github PK

View Code? Open in Web Editor NEW
162.0 5.0 83.0 369 KB

FreeSWITCH externals projects

Home Page: https://zhouhailin.github.io/freeswitch-externals/

License: Apache License 2.0

Java 100.00%
freeswitch freeswitch-event-socket event-socket freeswitch-esl esl esl-client voip java spring-boot

freeswitch-externals's People

Contributors

codacy-badger avatar dependabot[bot] avatar xhuanlee avatar zhouhailin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

freeswitch-externals's Issues

BUG : ESL接收中文消息乱码

接收ASR消息如下:

¥ᆬᄑ¥ᆬᄑ¥ᆬᄑ¥ᆬᄑ ̄タツ 2490 4120 8faf3019e71a44a68108ff507fc59751 f5ae0db56a6844a1-3.wav ¥ᆬᄑ¥ᆬᄑ¥ᆬᄑ¥ᆬᄑ ̄タツ

Error when Autowired InboundClient on many EslEventHandler class

I has 2 class implement EslEventHandler, that is HeartbeatEslEventHandler and ReScheduleEslEventHandler. On both that EslEventHandler's subclasses include code:
@Autowired
private InboundClient inboundClient;

So, after bean IEslEventListenerTemplate initialized, method afterPropertiesSet() got only one bean of subclass EslEventHandler.

线程池未定义队列大小导致内存溢出

线程池未定义队列大小导致内存溢出:

link.thingscloud.freeswitch.esl.inbound.AbstractNettyInboundClient

publicExecutor = new ScheduledThreadPoolExecutor(option.publicExecutorThread(), new DefaultThreadFactory("publicExecutor", true)); privateExecutor = new ScheduledThreadPoolExecutor(option.privateExecutorThread(), new DefaultThreadFactory("privateExecutor", true));

疑似event命令重复拼接


    /** {@inheritDoc} */
    @Override
    public void handleAuthRequest(String addr, InboundChannelHandler inboundChannelHandler) {
        log.info("Auth requested[{}], sending [auth {}]", addr, "*****");
        for (ServerOption serverOption : option().serverOptions()) {
            String password = serverOption.password();
            if (password == null) {
                password = option().defaultPassword();
            }
            if (StringUtils.equals(addr, serverOption.addr())) {
                EslMessage response = inboundChannelHandler.sendSyncSingleLineCommand("auth " + password);
                log.debug("Auth response [{}]", response);
                if (response.getContentType().equals(EslHeaders.Value.COMMAND_REPLY)) {
                    CommandResponse reply = new CommandResponse("auth " + password, response);
                    serverOption.state(ConnectState.AUTHED);
                    log.info("Auth response success={}, message=[{}]", reply.isOk(), reply.getReplyText());
                    if (!option().events().isEmpty()) {
                        StringBuilder sb = new StringBuilder();
                        sb.append("event plain ");
                        for (String event : option().events()) {
                            sb.append(event).append(" ");
                        }
                        setEventSubscriptions(addr, "plain", sb.toString());
                    }
                } else {
                    serverOption.state(ConnectState.AUTHED_FAILED);
                    log.error("Bad auth response message [{}]", response);
                    throw new IllegalStateException("Incorrect auth response");
                }
            }
        }
    }

setEventSubscriptions(addr, "plain", sb.toString());
这句是不是有个bug呢,因为setEventSubscriptions里面的逻辑是'event ' + 'plain ' + sb.toString(),
这时会造成重复拼接,以all为例,最后出来一个event plain event plain all
仅看了代码,没有调试~

java.lang.OutOfMemoryError: Direct buffer memory

jdk 版本

openjdk version "11" 2018-09-25
OpenJDK Runtime Environment 18.9 (build 11+28)
OpenJDK 64-Bit Server VM 18.9 (build 11+28, mixed mode)

OS

CentOS Linux release 7.5.1804 (Core)

异常

[2019-11-20 07:36:21:766] [nioEventLoopGroup-2-1] [WARN] - io.netty.channel.DefaultChannelPipeline.onUnhandledInboundException(DefaultChannelPipeline.java:1164) - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.OutOfMemoryError: Direct buffer memory
	at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
	at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:758) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:734) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:245) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:227) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:147) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PooledByteBufAllocator.newDirectBuffer(PooledByteBufAllocator.java:342) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:187) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBufAllocator.directBuffer(AbstractByteBufAllocator.java:178) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBufAllocator.ioBuffer(AbstractByteBufAllocator.java:139) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.DefaultMaxMessagesRecvByteBufAllocator$MaxMessageHandle.allocate(DefaultMaxMessagesRecvByteBufAllocator.java:114) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:147) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at java.lang.Thread.run(Thread.java:834) [?:?]
[2019-11-20 07:36:22:374] [nioEventLoopGroup-2-1] [WARN] - io.netty.channel.DefaultChannelPipeline.onUnhandledInboundException(DefaultChannelPipeline.java:1164) - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.OutOfMemoryError: Direct buffer memory
	at java.nio.Bits.reserveMemory(Bits.java:175) ~[?:?]
	at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:118) ~[?:?]
	at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:317) ~[?:?]
	at io.netty.buffer.PoolArena$DirectArena.allocateDirect(PoolArena.java:758) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena$DirectArena.newChunk(PoolArena.java:734) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena.allocateNormal(PoolArena.java:245) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena.allocate(PoolArena.java:227) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PoolArena.reallocate(PoolArena.java:397) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.PooledByteBuf.capacity(PooledByteBuf.java:119) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:310) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:281) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1118) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1111) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1102) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.handler.codec.ByteToMessageDecoder$1.cumulate(ByteToMessageDecoder.java:96) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:281) ~[netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:352) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1422) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:374) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:360) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:931) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:163) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:700) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:635) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:552) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1044) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [netty-all-4.1.42.Final.jar!/:4.1.42.Final]
	at java.lang.Thread.run(Thread.java:834) [?:?]

异步发送命令还是调用sendSyncSingleLineCommand?

freeswitch-esl/src/main/java/link/thingscloud/freeswitch/esl/inbound/handler/InboundChannelHandler.java

public String sendAsyncCommand(final String command) {
/*
* Send synchronously to get the Job-UUID to return, the results of the actual
* job request will be returned by the server as an async event.
*/
EslMessage response = sendSyncSingleLineCommand(command);
if (isTraceEnabled) {
log.trace("sendAsyncCommand command : {}, response : {}", command, response);
}
if (response.hasHeader(EslHeaders.Name.JOB_UUID)) {
return response.getHeaderValue(EslHeaders.Name.JOB_UUID);
} else {
log.warn("sendAsyncCommand command : {}, response : {}", command, EslHelper.formatEslMessage(response));
throw new IllegalStateException("Missing Job-UUID header in bgapi response");
}
}

sendAsyncCommand 方法内部还是调用
sendSyncSingleLineCommand
的方法,这样岂不是异步调用的也是同步命令?

连接断开的时候没有重新监听事件

freeswitch不知道为啥,大概一天会断开一次连接,重新连上的时候之前监听的事件就收不到了。
我试过用ServerConnectionListener在连接连上的时候去监听,但好像这个事件发生的时候,client还没有初始化,调用监听事件会报没有权限,所以我现在是加了异步延时去弄,这个问题有其他好的办法解决吗

同步调用时,单线程池因为服务端异常,请求一直阻塞

单线程池调用link.thingscloud.freeswitch.esl.inbound.handler.InboundChannelHandler#sendSyncSingleLineCommand方法时,如果服务端挂了或者重启了一直收不到响应时,这个线程会一直阻塞

public EslMessage sendSyncSingleLineCommand(final String command) {
        if (isTraceEnabled) {
            log.trace("sendSyncSingleLineCommand command : {}", command);
        }
        SyncCallback callback = new SyncCallback();
        syncLock.lock();
        try {
            syncCallbacks.add(callback);
            channel.writeAndFlush(command + MESSAGE_TERMINATOR);
        } finally {
            syncLock.unlock();
        }
        return callback.get();
    }

callback.get()方法一直在等待返回,link.thingscloud.freeswitch.esl.inbound.handler.InboundChannelHandler.SyncCallback中的get方法中的latch.await()这个方法是否可以设置一个等待超时

 /**
         * Block waiting for the countdown latch to be released, then return the
         * associated response object.
         *
         * @return msg
         */
        EslMessage get() {
            try {
                log.trace("awaiting latch ... ");
                latch.await();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

            log.trace("returning response [{}]", response);
            return response;
        }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.