-
SocketIO多线程卡死问题
最近公司需要用mediasoup实现一套媒体服务,本着快速开发所以服务端我还是使用了NodeJS开发,所以选择SocketIO作为信令通道。但是接入安卓的时候出现一个奇怪的问题就是socket.emit使用ack回调的时候,使用future总是get那里卡死了。后来看了Java实现的SocketIO的EventThread的代码实现发现里面用的是一个单线程的线程池。这样就有个问题,就是如果我的ack回调如果调用一个方法这个方法里面也有一个ack回调,就会导致后面的ack等待前一个ack回调结束,get等到就会直接阻塞整个过程。```publicstaticvoidnextTick(finalRunnabletask){ExecutorServiceexecutor;synchronized(EventThread.class){counter++;if(service==null){service=Executors.newSingleThreadExecutor(THREAD_FACTORY);}executor=service;}executor.execute(newRunnable(){@Overri...
SocketIO -
Linux写入U盘文件丢失问题
用代码向U盘写入文件,明明提示文件写入完成,流也关闭了,但是直接拔出U盘的时候文件还是没有数据。后来发现执行`umount`命令数据时存在的,所以估计是数据还在系统缓存里面没有刷出,所以使用`sync`命令刷出缓存就好了。
Linux U盘 -
Input buffer exhausted before END element found
安卓使用`MediaMuxer`录制的视频网页播放不了,但是播放器可以播放,并且`ffmpeg`提示`InputbufferexhaustedbeforeENDelementfound`。研究了一段时间发现,原来是录制开始写入数据`writeSampleData`后还在调用`addTrack`的原因,需要所有`track`添加完成才能调用`writeSampleData`写数据。
Android MediaMuxer -
Windows Terminal
最近找一个代替`MobaXterm`的工具,所以使用`WindowsTerminal`。```wingetinstalloh-my-poshoh-my-poshfontinstalloh-my-poshinitpwsh--config"$env:POSH_THEMES_PATH\cinnamon.omp.json"|Invoke-Expression```
Windows Terminal -
Windows C++
环境:```vsvscodevcpkgMSVCMinGWMSYS2CMakeCygwin```我的环境:vscode+vcpkg+cmake+msvc##MSYS2使用安装完成执行两次`pacman-Syu`和`pacman-Smingw-w64-x86_64-toolchain````pacman-S#安装软件pacman-U#安装本地包pacman-Syu#同步Msys2源并更新pacman-Sy#仅同步源pacman-Su#更新系统pacman-Sy#同步源后再安装软件pacman-R#该命令将只删除包不包含该包的依赖pacman-Rs#在删除包的同时也将删除其依赖pacman-Rd#在删除包时不检查依赖pacman-Ss#这将搜索含关键字的包pacman-Qi#查看有关包的信息```##vcpkg使用```vcpkgsearch[pat]搜索可安装的包vcpkginstall...安装包vcpkgremove...卸载包vcpkgremove--outdated卸载所有过期包vcpkglist列出已安装的包vcpkgupdate显示用于更新的包列表vcpkgupgrade重新生成所有过期包vcpkgh...
Windows Eclipse C++ vcpkg MinGW MSYS2 CMake Cygwin -
MinGW版本含义
```x86_64-posix-sjljx86_64-posix-sehx86_64-win32-sjljx86_64-win32-sehi686-posix-sjlji686-posix-dwarfi686-win32-sjlji686-win32-dwarf```*SEH:调用系统机制处理异常,支持32、64位系统,GCC不支持(即将支持)*SJLJ:跨平台,支持32、64位系统,运行速度稍慢,GCC不支持。*DWARF:一种带调试信息DWARF-2(DW2)EH的包,所以比一般的包尺寸大,仅支持32位系统。*x86_64:简称X64,64位操作系统。*i686:32位操作系统(i386的子集),差不多奔腾2之后的CPU都是可以用的。*posix:启用了C++11多线程特性*win32:未启用
MinGW -
Nginx文件上传Tomcat需要文件传完才能收到问题
最近在做文件断点上传,发现每次都是文件上传完了之后才能收到文件流,改了很多种方法,最后发现原来是`Nginx`的问题。需要关闭配置:`proxy_request_buffering`,同样还有一个配置`proxy_buffering`功能相反。推荐一篇Nginx文章:[https://blog.csdn.net/u013905744/article/details/110915561](https://blog.csdn.net/u013905744/article/details/110915561)
Nginx Tomcat SpringBoot -
WebRTC配置STUN/TURN
参考配置:[https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/urls](https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/urls)#STUN```newRTCPeerConnection({iceServers:[{urls:"stun:stunserver.example.org"}]});```#TURN```newRTCPeerConnection({iceServers:[{urls:"turn:turnserver.example.org",username:"webrtc",credential:"turnpassword"}]});newRTCPeerConnection({iceServers:[{urls:["turns:turnserver.example.org","turn:turnserver.example.org"],username:"webrtc",credential:"turnpassword"}]});newRTCPee...
WebRTC STUN TURN -
Git大小写问题
系统里面修改了文件名称的大小写,但是发现没有效果。然后修改`.git/config`配置`ignorecase=false`,然后大小写能够正常提交了。但是切换分支又出现了问题,提示错误:```Thefollowinguntrackedworkingtreefileswouldbeoverwrittenbycheckout:```最后把上面的配置改了回去分支切换又正常了😂😂😂
Git Windows -
Java1.8证书问题
今天搭建一个项目环境,因为用的时`Java1.8`,最开始用的系统自带的,但是发现编译不了,提示如下错误:```[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile(default-compile)onprojectjshERP-boot:Compilationfailure[ERROR]Nocompilerisprovidedinthisenvironment.PerhapsyouarerunningonaJREratherthanaJDK?```所以就去`openjdk`下载了一个安装包,但是编译又提示错误:```Executiondefault-testofgoalorg.apache.maven.plugins:maven-surefire-plugin:2.20.1:testfailed:Pluginorg.apache.maven.plugins:maven-surefire-plugin:2.20.1oroneofitsdependenciescouldnotberesolve...
Java1.8 -
Linux自动挂载U盘
##安装驱动```yuminstallntfs-3gyuminstallfuse-exfatyuminstallexfat-utils```##添加配置```vim/etc/udev/rules.d/auto-mount.rules####USBKERNEL=="sd[a-z]",SUBSYSTEM=="block",ACTION=="add",RUN+="/data/usb/auto-mount.sh%k/mnt/usb"KERNEL=="sd[a-z]",SUBSYSTEM=="block",ACTION=="remove",RUN+="/data/usb/auto-mount.sh%k/mnt/usb"KERNEL=="sd[a-z][0-9]",SUBSYSTEM=="block",ACTION=="add",RUN+="/data/usb/auto-mount.sh%k/mnt/usb"KERNEL=="sd[a-z][0-9]",SUBSYSTEM=="block",ACTION=="remove",RUN+="/data/usb/auto-mount.sh%k/mnt/usb"####CFCar...
Linux U盘自动挂载 -
HikariCP连接池异常
由于项目里面需要连接多个数据库,所以自己配置注入了一个`DataSource`,但是用了一段时间发现提示下面异常:```java.sql.SQLTransientConnectionException:HikariPool-2-Connectionisnotavailable,requesttimedoutafter30000ms.atcom.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:695)atcom.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:197)atcom.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:162)atcom.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128)```最开始还以为是数据库的问题,后来发现原来是自己代码有问题,就是获取连接之后,以为是连接池所以...
HikariCP 连接处 -
FFmpeg学习
##FFmpeg安装```#apt安装sudoaptinstallffmpeg#源码安装#nasmcd/data/devwgethttps://www.nasm.us/pub/nasm/releasebuilds/2.16/nasm-2.16.tar.gztar-zxvfnasm-2.16.tar.gzcdnasm-2.16/./configuresudomake-j8&&sudomakeinstall#yasmcd/data/devwgethttps://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gztar-zxvfyasm-1.3.0.tar.gzcdyasm-1.3.0/./configuresudomake-j8&&sudomakeinstall#libvpx?--enable-gpl--enable-libvpxcd/data/dev#gitclonehttps://chromium.googlesource.com/webm/libvpx.gitgitclonehttps://github.com/w...
FFmpeg -
ES重建索引
今天发现ES索引建错了,很难受记录一下重建过程:```#查看索引结构curlhttp://elastic:elastic@localhost:9200/index_log#新建临时索引curl-XPUThttp://elastic:elastic@localhost:9200/index_log_back#拷贝临时索引curl-XPOST-H"Content-Type:application/json"http://elastic:elastic@localhost:9200/_reindex-d'{"source":{"index":"index_log"},"dest":{"index":"index_log_back"}}'#查询索引状态curlhttp://elastic:elastic@localhost:9200/_cat/indices#删除旧的索引curl-XDELETEhttp://elastic:elastic@localhost:9200/index_log#重启应用建立索引#还原数据curl-XPOST-H"Content-Type:application/json"http://el...
ES -
Linux时间错误
一般情况Linux联网都会通过`ntp`服务自动同步时间,但是最近的机器大部分都是离线系统,导致时间错乱。一开始以为是`coms`电池没电了,后来发现原来就是硬件时间错了,所以我们直接修改硬件时间即可:```#设置系统时间date-s'2022111111:11:11'#查看硬件时间hwclock--show#硬件时间同步系统时间hwclock--systohc#系统时间同步硬件时间hwclock--hctosys```
Linux -
MyBatisPlus解决SQLServer分页问题
最近有个项目需要迁移`SQLServer`,原来使用的`MySQL`,发现有些`SQL`有些问题,特别是分页统计条数。原来使用`MySQL`时子查询里面可以含有`orderby`,但是`SQLServer`不行,提示:```org.springframework.jdbc.UncategorizedSQLException:###Errorqueryingdatabase.Cause:com.microsoft.sqlserver.jdbc.SQLServerException:TheORDERBYclauseisinvalidinviews,inlinefunctions,derivedtables,subqueries,andcommontableexpressions,unlessTOP,OFFSETorFORXMLisalsospecified.```其实默认`MyBatisPlus`是解决了这个问题的,简单语句会去掉排序,复杂语句通过`TOP100PERCENT`解决了,但是还是存在部分有问题。如果语句之中别名存在关键字时就会导致解析不了`SQL`,最好的解决方法就是修改别名。也可以通过将排序字段设...
MyBatisPlus SQLServer -
DBeaver优化
以前一直用的`Navicat`,现在不能用了,改用`DBeaver`了,然后调整了一些设置比较方便。##自动生成别名```首选项->编辑器->SQL编辑器->代码补全->插入表的别名```
DBeaver -
微信公众号获取消息换行问题
今天仔细看了一下微信公众号收到的消息,发现换行符不见了,后来仔细排查了一下才发现自己写的BUG:```//错误代码finalStringBuilderbuilder=newStringBuilder();try(finalBufferedReaderreader=newBufferedReader(newInputStreamReader(request.getInputStream()));){Stringline=null;while((line=reader.readLine())!=null){//注意添加换行builder.append(line);}}```看到没有,`readLine`然后没有拼接换行符所以导致丢失了,改为`builder.append("\r\n").append(line);`即可。
微信公众号 -
SpringBoot获取WebSocket IP地址
在`SpringBoot`中通过`RequestContextHolder.getRequestAttributes()`获取不到`WebSocket`的`request`请求,所以获取客户端真实IP地址需要通过下面这种方法:```/***WebSocket配置器**@authoracgist*/@Slf4jpublicclassWebSocketConfiguratorextendsServerEndpointConfig.Configurator{publicstaticfinalStringCLIENT_IP="CLIENT_IP";@OverridepublicvoidmodifyHandshake(ServerEndpointConfigconfig,HandshakeRequestrequest,HandshakeResponseresponse){StringclientIP=null;Listlist=null;finalMap>headers=request.getHeaders();log.debug("WebSocket头部:{}",headers);if(CollectionUt...
SpringBoot WebSocket IP -
SpringCloud OAuth2国际化失效的问题
这里使用旧的OAuth2模块:```org.springframework.cloudspring-cloud-starter-oauth2```现在需要自定义一个授权`grunt_type`,实现两个组件即可`AuthenticationProvider`和`AbstractTokenGranter`。##白名单通过帐号直接授权Token```@Slf4jpublicclassMobileAuthenticationProviderimplementsAuthenticationProvider{@AutowiredprivateWhiteIPPropertieswhiteIPProperties;@AutowiredprivateUserDetailsServiceuserDetailsService;@OverridepublicAuthenticationauthenticate(Authenticationauthentication)throwsAuthenticationException{finalMobileTokentoken=(MobileToken)authentication;fin...
SpringCloud OAuth2