GithubHelp home page GithubHelp logo

kerryjiang / supersocket Goto Github PK

View Code? Open in Web Editor NEW
3.8K 276.0 1.1K 27.08 MB

SuperSocket is a light weight, cross platform and extensible socket server application framework.

License: Apache License 2.0

C# 99.87% Shell 0.13%
csharp socket socketserver realtime-communication tcp udp

supersocket's Introduction

SuperSocket

Join the chat at https://gitter.im/supersocket/community Build NuGet Version NuGet Badge

SuperSocket is a light weight extensible socket application framework. You can use it to build an always connected socket application easily without thinking about how to use socket, how to maintain the socket connections and how socket works. It is a pure C# project which is designed to be extended, so it is easy to be integrated to your existing systems as long as they are developed in .NET language.


Nuget Packages
Package MyGet Version NuGet Version Download
SuperSocket
(all in one)
MyGet Version NuGet Version NuGet Download
SuperSocket.WebSocketServer
(Use SuperSocket.WebSocket.Server instead)
MyGet Version NuGet Version NuGet Download
SuperSocket.ProtoBase MyGet Version NuGet Version NuGet Download
SuperSocket.Primitives MyGet Version NuGet Version NuGet Download
SuperSocket.Channel MyGet Version NuGet Version NuGet Download
SuperSocket.Connection MyGet Version NuGet Version NuGet Download
SuperSocket.Kestrel MyGet Version NuGet Version NuGet Download
SuperSocket.Server MyGet Version NuGet Version NuGet Download
SuperSocket.Server.Abstractions MyGet Version NuGet Version NuGet Download
SuperSocket.Command MyGet Version NuGet Version NuGet Download
SuperSocket.SessionContainer MyGet Version NuGet Version NuGet Download
SuperSocket.Client MyGet Version NuGet Version NuGet Download
SuperSocket.Client.Proxy MyGet Version NuGet Version NuGet Download
SuperSocket.WebSocket MyGet Version NuGet Version NuGet Download
SuperSocket.WebSocket.Server MyGet Version NuGet Version NuGet Download
SuperSocket.Udp MyGet Version NuGet Version NuGet Download
SuperSocket.GZip MyGet Version NuGet Version NuGet Download
SuperSocket.SerialIO MyGet Version NuGet Version NuGet Download

Nightly build packages: https://www.myget.org/F/supersocket/api/v3/index.json


SuperSocket 2.0 Roadmap:

  • 2024:
    • More documents
    • Performance test/tuning
    • Fix issues of the existing features
    • Other features requested by users
    • Stable release

supersocket's People

Contributors

alanyuen avatar billybraga avatar chucklu avatar dependabot[bot] avatar ezrealj avatar forsakenyang avatar haylax avatar kerryjiang avatar kmiterror avatar martinmine avatar pea-sys avatar robin-rexstedt-stretch avatar semihokur avatar shenghao0219 avatar shuang888 avatar songxt avatar thompson-tomo avatar ven-lee avatar volodymyravetisian avatar wj8400684 avatar yazgoo avatar yedajiang44 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  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

supersocket's Issues

Async ExecuteJsonCommand

instead of this: m_AsyncJsonCommandAction.BeginInvoke(session, session.CurrentToken, commandInfo, OnAsyncJsonCommandExecuted, session);

would this work? : var t = Task.Factory.StartNew
(() =>
{
ExecuteAsyncJsonCommand(session, session.CurrentToken, commandInfo);
});
t.Wait();
}

you do not have access to session.CurrentToken its in the main thread or seperate thead. this would ensure that this:
for (var i = 0; i < filters.Length; i++)
{
var filter = filters[i];

            filter.OnCommandExecuting(commandContext);

            if (commandContext.Cancel)
                break;
        }

is called after the command is finished. please advise.

Switch to TLS in an active session

Hi
I want add TLS support to my smtp server project. A smtp session starts without TLS and after the command "STARTTLS" the session switch to TLS.

I test with the following code, but this not work

#Config
var config = new SuperSocket.SocketBase.Config.ServerConfig();
config.Certificate = new SuperSocket.SocketBase.Config.CertificateConfig() { FilePath = "test.pfx", Password = "test" };

#Session receive "STARTTLS" command (public class SmtpSession : AppSession<SmtpSession>)
this.SecureProtocol = System.Security.Authentication.SslProtocols.Tls;

I found a other example (not use supersocket) this one work
https://github.com/cosullivan/SmtpServer/blob/master/Src/SmtpServer/Protocol/StartTlsCommand.cs

var stream = new SslStream(context.Text.GetInnerStream(), true);
await stream.AuthenticateAsServerAsync(_certificate, false, SslProtocols.Default, true);
context.Text = new NetworkTextStream(stream);

System.InvalidOperationException: "现在已经正在使用此 SocketAsyncEventArgs 实例进行异步套接字操作。";

Win2008R2-x64-企业版 服务器
Framework 版本: v4.0.30319

这个问题经常发生, 只能重启服务来解决.
异常如下:
Unexpected error
System.InvalidOperationException: "现在已经正在使用此 SocketAsyncEventArgs 实例进行异步套接字操作。";
在 System.Net.Sockets.SocketAsyncEventArgs.StartOperationCommon(Socket socket)
在 System.Net.Sockets.Socket.ReceiveAsync(SocketAsyncEventArgs e)
在 SuperSocket.SocketEngine.AsyncSocketSession.StartReceive(SocketAsyncEventArgs e, Int32 offsetDelta) 位置 e:\Workshop\SuperSocket\v1.6\SocketEngine\AsyncSocketSession.cs:行号 148

现在已经正在使用此 SocketAsyncEventArgs 实例进行异步套接字操作

hi, 用的类库是最新的1.6.5.0, 但是一样出现此问题,运行一段时间后出现

2015-11-10 19:50:12,601 [14712] ERROR PWSS:90_a.b.c.d - Session: 87b5fd71-6844-403f-80e8-3440900b9b1b/a1.b1.c1.d1:8323
Unexpected error
System.InvalidOperationException: "现在已经正在使用此 SocketAsyncEventArgs 实例进行异步套接字操作。";
在 System.Net.Sockets.SocketAsyncEventArgs.StartOperationCommon(Socket socket)
在 System.Net.Sockets.Socket.ReceiveAsync(SocketAsyncEventArgs e)
在 SuperSocket.SocketEngine.AsyncSocketSession.StartReceive(SocketAsyncEventArgs e, Int32 offsetDelta) 位置 d:\WorkShop\SuperSocket\v1.6\SocketEngine\AsyncSocketSession.cs:行号 148

1.6.6运行一段时间后就报这个错误,异常信息: System.InvalidOperationException

异常信息: System.InvalidOperationException
堆栈:
在 System.Net.Sockets.SocketAsyncEventArgs.StartConfiguring()
在 System.Net.Sockets.SocketAsyncEventArgs.SetBufferInternal(Byte[], Int32, Int32)
在 SuperSocket.SocketEngine.AsyncSocketServer.SessionClosed(SuperSocket.SocketBase.ISocketSession, SuperSocket.SocketBase.CloseReason)
在 System.Action`2[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[SuperSocket.SocketBase.CloseReason, SuperSocket.SocketBase, Version=1.6.6.0, Culture=neutral, PublicKeyToken=null]].Invoke(System._Canon, SuperSocket.SocketBase.CloseReason)
在 SuperSocket.SocketEngine.SocketSession.OnSendEnd(Boolean)
在 SuperSocket.SocketEngine.SocketSession.OnSendingCompleted(SuperSocket.Common.SendingQueue)
在 SuperSocket.SocketEngine.AsyncSocketSession.OnSendingCompleted(System.Object, System.Net.Sockets.SocketAsyncEventArgs)
在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
在 System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net.Sockets.SocketFlags)
在 System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped
)
在 System.Threading.IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped)

Why cannot i find the AnyLog.dll in version 1.6?

I have download the source for version 1.6 several minutes ago. But I just cannot compile the project for SocketBase.Net45? Than i find that this source not include the AnyLog.dll, so what can i do ?

NuGet missing SocketEngine DLL

Hi when getting 1.6.5 on NuGet this is what we get in the nupkg :

      <reference file="SuperSocket.Common.dll" />
      <reference file="SuperSocket.SocketBase.dll" />
      <reference file="SuperSocket.Facility.dll" />

When trying to launch the example :

if (!appServer.Setup(2012)) //Setup with listening port

It fails saying that it can't find SuperSocket.SocketEngine.dll,

Plus you specify on your doc that
"Add SuperSocket's dll (SuperSocket.Common.dll, SuperSocket.SocketBase.dll, SuperSocket.SocketEngine.dll) in this project's reference"

Why is Facility.dll referenced instead of SocketEngine in NuGet ? It really seems like a simple typo to me :)

Thanks

PS : When adding the DLL manually to the reference it works

1.6.2.0 of SuperSocket failes SuperWebSocket

Hi Kerry,

Just upgraded SuperSocket to 1.6.2.0 from NuGet. Afterwards, my SuperWebSocket Start call comes back with this error: "You cannot start a server instance which has not been setup yet."

The code worked perfectly before the SuperSocket upgrade.

Thanks!

v1.6分支下的QuickStart下的BroadcastService逻辑问题

private Dictionary<string, List> broadcastDict = new Dictionary<string, List>(StringComparer.OrdinalIgnoreCase);
public BroadcastServer()
{
lock (broadcastSyncRoot)
{
//It means that device V001 will receive broadcast messages from C001 and C002,
//device V002 will receive broadcast messages from C002 and C003
broadcastDict["C001"] = new List { "V001" };
broadcastDict["C002"] = new List { "V001", "V002" };
broadcastDict["C003"] = new List { "V002" };
}
}
internal void BroadcastMessage(BroadcastSession session, string message)
{
lock (broadcastSyncRoot)
{
if(!broadcastDict.TryGetValue(session.DeviceNumber, out targetDeviceNumbers))
return;
}
}
上面这段代码,broadcastDict存放的是CXXX,以及将要发送给消息的设备集合。
然后broadcastDict.TryGetValue(session.DeviceNumber, out targetDeviceNumbers)这个获取判断是把设备号码作为key传递进去的。这样操作的话,targetDeviceNumbers恒等于null了。

不过,我尝试把C001作为设备号码来进行传递的时候,就可以。不过这样的话,逻辑上就是有问题的了。

IWorkItem接口的继承问题

interface IWorkItemBase : IStatusInfoSource, ISystemEndPoint{}
interface IWorkItem : IStatusInfoSource, IWorkItemBase{}
IWorkItemBase 已经继承了IStatusInfoSource
IWorkItem 继承了IWorkItemBase的时候,不会把之前的继承关系继承过来吗?
看了类图,感觉很奇怪,形成了一个环,接口是这样用的吗?

貌似网络不好,我上传不了类图

WebSocketServer SetupCommands doesn't call base.SetupCommands

Shouldn't SetupCommands call the base method ? I was trying to add my own command Loader and the code loading the custom commands seems to be in the AppServerBase SetupCommands ( Which is never called )

        protected override bool SetupCommands(Dictionary<string, ICommand<TWebSocketSession, IWebSocketFragment>> discoveredCommands)
        {
            var commands = new List<ICommand<TWebSocketSession, IWebSocketFragment>>
                {
                    new HandShake<TWebSocketSession>(),
                    new Text<TWebSocketSession>(),  
                    new Binary<TWebSocketSession>(),
                    new Close<TWebSocketSession>(),
                    new Ping<TWebSocketSession>(),
                    new Pong<TWebSocketSession>(),
                    new Continuation<TWebSocketSession>(),
                    new Plain<TWebSocketSession>()
                };

            commands.ForEach(c => discoveredCommands.Add(c.Name, c));

            if (!SetupSubProtocols(Config))
                return false;

            return true;
        }

NullReferenceException, process crashed

Unhandled exception: System.NullReferenceException: 
   WebSocket4Net.Protocol.DraftHybi10Processor.SendHandshake(WebSocket websocket)
   SuperSocket.ClientEngine.AsyncTcpSession.OnGetSocket(SocketAsyncEventArgs e)
   System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
   System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   System.Net.Sockets.SocketAsyncEventArgs.FinishWrapperConnectSuccess(Socket connectSocket, Int32 bytesTransferred, SocketFlags flags)
   System.Net.Sockets.MultipleConnectAsync.Succeed()
   System.Net.Sockets.MultipleConnectAsync.InternalConnectCallback(Object sender, SocketAsyncEventArgs args)
   System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(SocketAsyncEventArgs e)
   System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(SocketError socketError, Int32 bytesTransferred, SocketFlags flags)
   System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

WebSocket4Net, 0.14.1.0 from NuGet.

FixedHeaderReceiveFilter does not work with single message

Dear Jiang,

FixedHeaderReceiveFilter在只收到一个消息的情况下CanResolvePackage返回为false,不会调用ResolvePackage; 只有后面继续有消息过来,之前的第一个消息才会被ResolvePackage。

Regards
askdong

ValidateClientCertificate session doesn't include path.

I am using this override method to do additional cert checks. I am listening for websocket connections with different paths; the path portion of the connection url gives clues to the ValidateClientCertificate about whether not the cert validation is required, and if so, what to check. The path value IS available when the NewSessionConnected handler is triggered; would it be possible to have this value assigned earlier so it's available to the custom ValidateClientCertificate method?

ConfigurationErrorsException: The configuration file has been changed by another program.

When editing and save app.config with Notepad++ at runtime, process crashes with unhandled exception:

System.Configuration.ConfigurationErrorsException: The configuration file has been changed by another program. (***Server.exe.config)
   в System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   в System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   в System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   в System.Configuration.Configuration.GetSection(String sectionName)
   в SuperSocket.SocketEngine.ConfigurationWatcher.OnConfigFileUpdated(String filePath, String sectionName, IBootstrap bootstrap)
   в SuperSocket.SocketEngine.ConfigurationWatcher.<>c__DisplayClass2.<Watch>b__1(Object s, FileSystemEventArgs e)
   в System.IO.FileSystemWatcher.OnChanged(FileSystemEventArgs e)
   в System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
   в System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPointer)
   в System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

SuperSocket 1.6.5.0

HandleSocketEventComplete + NullRefernceException

SaePoolResource.cs:

if(config.Mode != SocketMode.Udp)
{
state.Sae.Completed += socketEventComplete.HandleSocketEventComplete;
}

AsyncSocketSession.cs:
if (result.State == ProcessState.Cached)
{
e.UserToken = null;
var newState = m_SaePoolForReceive.Get();
e = newState.Sae;
e.UserToken = newState;
newState.SocketSession = this;
}

HandleSocketEventComplete 有可能在UserToken,SocketSession未附值前已被調用

Asyn break

This code breaks... the async command is not done executing. the post filter are being called. maybe the filters should be in a command completed event.???

if (!commandContext.Cancel)
{
ExecuteCommand(session, requestInfo);

            for (var i = 0; i < filters.Length; i++)
            {
                var filter = filters[i];
                filter.OnCommandExecuted(commandContext);
            }
        }

Protobuf-net

How can I serialize/deserialize data with Protobuf ?

How can I use command with SuperSocket.WebSocket?

Hello, I'm new to SuperSocket and SuperSocket.WebSocket.

I would like to make an server that listen a data from mobile via socket and listen a data from web via websocket.

Every thing is work fine in the start. but when I see the Usage of Command section on http://docs.supersocket.net/v1-6/en-US/A-Telnet-Example I would like to convert all of my RequestReceived event to commands.

However I can't find a example of using a command with SuperSocket.WebSocket. I try to create a class like a code below but it never called.

class ECHO : CommandBase<WebSocketSession, IWebSocketFragment>
{
    public override void ExecuteCommand(WebSocketSession session, IWebSocketFragment requestInfo)
    {
        session.Send("test");
    }
}

Could you please suggest me, how can I use command with SuperSocket.WebSocket?

Thank you very much.

Failed to read cookie

Failed to read cookie, key: cookie_key_xxx, value: value1=3&value2=3985642&value3=hf%97z%ce%98%96f&value4=5BCE36B6E3600B5823ABC1BC43B387AA6B335032.

Error in sending response to clients

Hi,

We have used Super Socket to create a TCPServer for GPS Tracking devices.

For some clients we have issues in sending the response (Acknowledgement) from Super Socket Server.

We enabled the Logging for Super Socket and the error been logged is:

Caller: SendSync, file path: d:\WorkShop\SuperSocket\v1.6\SocketEngine\AsyncSocketSession.cs, line number: 183
System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at SuperSocket.SocketEngine.AsyncSocketSession.SendSync(SendingQueue queue)
2016-06-20 19:24:30,063 [47] ERROR MyAppServer-35320229 - Session: 591919ef-adc7-487a-b523-b4ef299398ff/41.189.163.56:57895
Unexpected socket error: 10054

Please do you know what the issue here could be? How do we fix it - I have tried increasing Sending Time Out, and the Sending Queue Size etc. But still we are having the same problem.

1.6.3.0 版本 空引用异常

我使用 1.6.3.0 版本的做一个 WebSocket 服务器, 发现服务偶尔会重启, 事件查看器内日志:

Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: System.NullReferenceException
堆栈:
在 SuperSocket.SocketEngine.AsyncSocketSession.OnClosed(SuperSocket.SocketBase.CloseReason)
在 SuperSocket.SocketEngine.SocketSession.OnSendEnd(Boolean)
在 SuperSocket.SocketEngine.SocketSession.OnSendingCompleted(SuperSocket.Common.SendingQueue)
在 SuperSocket.SocketEngine.AsyncSocketSession.OnSendingCompleted(System.Object, System.Net.Sockets.SocketAsyncEventArgs)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
在 System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError, Int32, System.Net.Sockets.SocketFlags)
在 System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped_)
在 System.Threading.IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped)
`

System.Exception: Failed to find a service

Whenever I try to run SuperSocket.SocketService.exe, I get the following output:
Failed to initialize SuperSocket ServiceEngine! Please check error log for more information!

But I can't seem to find any logs!

I've stored my configuration in SuperSocket.SocketService.exe.config, and it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="superSocket"
            type="SuperSocket.SocketEngine.Configuration.SocketServiceConfig, SuperSocket.SocketEngine" />
    </configSections>

    <superSocket>
        <servers>
            <server name="LoginServer"
                    serverTypeName="Houdini.HoudiniServer"
                    ip="Any"
                    port="6112">
            </server>
        </servers>
  </superSocket>

</configuration>

I'm using Mono version 4.0.2 on OS X, and the NuGet package. All of the assemblies are in the same directory as the executable.

If I try running my program directly, I get the following

2015-08-04 04:33:40 ERROR DefaultBootstrap - System.Exception: Failed to find a service for server LoginServer!
  at SuperSocket.SocketEngine.WorkItemFactoryInfoLoader.LoadResult (System.Func`2 serverConfigResolver) [0x0018e] in <filename unknown>:0 
  at SuperSocket.SocketEngine.DefaultBootstrap.Initialize (System.Func`2 serverConfigResolver, ILogFactory logFactory) [0x0008e] in <filename unknown>:0 
2015-08-04 04:33:40 FATAL Houdini.MainClass - Failed to initialize!

Receiving Raw Data as byte array from client

Hello Kerry,

I appreciate the work you are doing with SuperSocket. I would like to know how to receive raw data as byte array from the client. Because there are time one want to handle encoding and decoding of bytes on its without going through some hassle. Is there a way to listen to such an event?

Change in active Session the ReceiveFilterFactory

Hello

I want add a new feature in my mail server project, by default "CommandLineReceiveFilterFactory" is a good protocol. But for "BDAT" i must change in a active session the receiveFilterFactory if this possible?

On the BDAT command i receive a octets count of the next message. I think a good FilterFactory for this part is the "FixedSizeReceiveFilter".

RFC
https://tools.ietf.org/html/rfc3030

SuperSocket on azure

you have some example of the updated azure?, the example that has the various errors when running.

Error building SuperSocket.SocketBase

I'm trying to build SuperSocket.SocketBase project in Xamarin Studio (MonoDevelop).

It builds with error:

../SuperSocket/SocketBase/AppServerBase.cs(31,31): Error CS0414: Warning as Error: The private field `SuperSocket.SocketBase.AppServer<TAppSession,TRequestInfo>.m_RequestHandlingTaskScheduler' is assigned but its value is never used (CS0414) (SuperSocket.SocketBase.Net45)

How to use it? - TRequestInfo Filter

Hello!

It really helped to SuperSocket when i working!

We are making file transfer server which included image processing module,
and available with muitiple users at once.

Client : Send compressed file(image), Receive big image file
Server : Receive compressed file(image), Send big image file

So. we're plan to using BinaryRequestInfo and IReceiveFilter(Factory)

My Question is

  1. TRequestInfo - readBuffer is shared by all connections in the same appServer instance. To get data what we want using filter(), Cut and get it in shared buffer using [offset, length] parameter?
  2. filter(..., toBeCopied, ...) - Could you explain some cases? when using [toBeCopied]? I don't understand just read in documentation.
  3. Is there way to access network stream directly and best example to save file from binary stream?

Thanks to reply it.
Best regards,

Crash when not setting disablePerformanceDataCollector to true

The program crashes when not setting disablePerformanceDataCollector to true

because of the execution of this in :

   DefaultBootstrap.cs (where the flag is checked)
   m_PerfMonitor = new PerformanceMonitor(m_Config, m_AppServers, serverManager, logFactory);

then in ProcessPerformanceCounterHelper.cs
var runnedInstances = processCategory.GetInstanceNames();

 has exited with code -1073741819 (0xc0000005) 'Access violation'

specs :
VS community 2015
Amd 8320E (8 cores)
Win 8.1 pro

quickstart文件夹的ConnectionFilter的配置文件

配置文件中有关于server以及serverTypes的配置,但是项目找不到相关的server






2015-03-24 08:42:00,549 [3776] ERROR DefaultBootstrap - Failed to create server instance EchoServer!
System.IO.FileNotFoundException: 未能加载文件或程序集“SuperSocket.QuickStart.EchoService”或它的某一个依赖项。系统找不到指定的文件。

能否移除log4net

依赖 common.log也可以 或者 实现自己的 ilog 可以自由选择log4net或者 nlog 或其他

Strong Naming in the 1.6 branch

Hello,
Supersocket.Websocket assembly is not strong named. All the others needed are.

This breaks dependencies where projects are strong named.

BufferListReader failing

Version: 6026f17

I am attempting to use the BeginEndMarkReceiveFilter class. Inside I am using the GetBufferReader(IList<ArraySegment>) extension method just like one of the samples. I could be doing something wrong, but I do not think so.

    public override StringPackageInfo ResolvePackage(IList<ArraySegment<byte>> packageData)
    {
        using (var reader = this.GetBufferReader(packageData))
        {
            var length = reader.Length;

            string message = reader.Skip(1).ReadString((int)length - 3, Encoding.ASCII);
            return new StringPackageInfo("", message, EmptyParameters);
        }
    }

I wrote a quick unit test that demonstrates the behavior. I get ArgumentOutOfRangeException

System.ArgumentOutOfRangeException : there is no enougth data
Parameter name: length
   at SuperSocket.ProtoBase.BufferListReader.ReadString(Int32 length, Encoding encoding) in BufferListReader.cs: line 662
   at SuperSocket.Test.Protocol.BufferListReaderTest.GetString() in BufferListReaderTest.cs: line 28

Unit Test Source:

[TestFixture]
public class BufferListReaderTest
{
    public static byte[] StartBlock = new byte[] { 0x0B };
    public static byte[] EndBlock = new byte[] { 0x1C, 0x0D };

    private static int MarkerLength = StartBlock.Length + EndBlock.Length;

    [Test]
    public void GetString()
    {
        string expected = "Hello";

        List<ArraySegment<byte>> segments = new List<ArraySegment<byte>>();
        segments.Add(new ArraySegment<byte>(GetBuffer(expected)));

        Assert.AreEqual(expected.Length + MarkerLength, segments[0].Array.Length);

        BufferListReader reader = new BufferListReader();
        reader.Initialize(segments);

        string actual = reader.Skip(1).ReadString((int)reader.Length - MarkerLength, Encoding.ASCII);

        Assert.AreEqual(expected, actual);
    }

    private byte[] GetBuffer(string message)
    {
        byte[] messageBytes = Encoding.ASCII.GetBytes(message);

        MemoryStream stream = new MemoryStream();
        stream.Write(StartBlock, 0, StartBlock.Length);
        stream.Write(messageBytes, 0, messageBytes.Length);
        stream.Write(EndBlock, 0, EndBlock.Length);

        return stream.ToArray();
    }
}

Configuring Supersocket in code using Setup does not work

I subclassed WebSocketServer<WebSocketSession>. Trying to configure the server using

this.Setup(new RootConfig(), new ServerConfig() { MaxRequestLength = 4096 , Port=8000});

does not work. this.Config is null and the server throws an error when calling the Start() function.

Issue trying to use telnet example

So I am trying to use the telnet example, pretty much copy/pasted it into a new console application in VisualStudio 2015.

If I then use Putty to open a telnet connection to the server (and yes, in Putty I am choosing the type to be 'Telnet') and then do the simple 'echo' command, it doesn't do it the first time but does do it the second time.

If I have the 'NewRequestReceived' function spit out to the console what the 'requestInfo.Key' is, the first time around it is a series of unprintable characters, the second time around (immediately after trying it the first time, exact same session) it shows 'echo'.

Screenshot of the issue: http://puu.sh/qLf5F/9dd99b64b3.png

Async

should this change:
protected override void ExecuteJsonCommand(TWebSocketSession session, TJsonCommandInfo commandInfo)
{
m_AsyncJsonCommandAction.BeginInvoke(session, session.CurrentToken, commandInfo, null, session);
}

to

protected override void ExecuteJsonCommand(TWebSocketSession session, TJsonCommandInfo commandInfo)
{
m_AsyncJsonCommandAction.BeginInvoke(session, session.CurrentToken, commandInfo, OnAsyncJsonCommandExecuted, session);
}

from null to OnAsyncJsonCommandExecuted.

Telnet socket and strings of text

This is really a 2 parter but both fall under similar things (in this case 'Telnet Socket').

Looking at the example it shows doing things like

foreach (var factor in requestInfo.Parameters.Select(p => Convert.ToInt32(p)))
{
  result *= factor;
}

However, when I do 'requestinfo.Parameters' I don't get an option for 'Select' at all, the only 'S' related option appears to be 'SetValue', there is however a 'GetValue' and I can do

requestInfo.Parameters.GetValue(0).ToString();

The other part of this is, is there a way to send a full text message instead of just a 1 word message?

eg. I want to send: echo "This is a test message"
another one might be instead of sending a message, I send a JSON string instead, eg: json { message: "This is a test message" }

Only reason I ask is because I am rewriting my Node.JS+Socket.IO websocket server in c# and the server has 2 parts to it.

Part 1 of my server is a websocket server that web browsers connect to.
Part 2 of my server is a TCP socket server that my production database server uses to communicate messages about batch processes back to the staff members that initiated the batch process.

On linux the batch processes do the following:

echo <channel>~<message> > /dev/tcp/<ip address of tcp socket server>/<port of tcp socket server>

The TCP Socket server then publishes that message to the redis server which holds all the websocket sessions.

Get the full message in appServer_NewRequestReceived event

Hello,

How do I get the full message appServer_NewRequestReceived event. For example, if I send a message "0000858 5521113 GT855500" in requestInfo.Key is "0000858" and requestInfo.Body comes "5521113 GT855500".

I wonder if there is a way where you can get the complete message passed on telnet?

Thanks for listening

Question about Tests

Hi kerryjiang,

I didn't find of the documentation statements about the testing procedure. Is there an easy way to mock server and session connections in order to perform command execution tests ?

It would be great to add some points in the documentation to increase the ease to put in production

Thanks for the lib

SocketException: The socket is not connected

Mono上运行,比较频繁的出现这个错

System.Net.Sockets.SocketException: The socket is not connected
  at System.Net.Sockets.Socket.get_RemoteEndPoint () [0x00000] in <filename unkn  n>:0
  at SuperSocket.SocketEngine.SocketSession..ctor (System.Net.Sockets.Socket cli  t) [0x00000] in <filename unknown>:0
  at SuperSocket.SocketEngine.AsyncSocketSession..ctor (System.Net.Sockets.Socket client, SuperSocket.SocketEngine.AsyncSocket.SocketAsyncEventArgsProxy socketA  ncProxy, Boolean isReset) [0x00000] in <filename unknown>:0
  at SuperSocket.SocketEngine.AsyncSocketSession..ctor (System.Net.Sockets.Socket client, SuperSocket.SocketEngine.AsyncSocket.SocketAsyncEventArgsProxy socketA  ncProxy) [0x00000] in <filename unknown>:0
  at SuperSocket.SocketEngine.AsyncSocketServer.ProcessNewClient (System.Net.Soc  ts.Socket client, SslProtocols security) [0x00000] in <filename unknown>:0
  at SuperSocket.SocketEngine.AsyncSocketServer.OnNewClientAccepted (ISocketListener listener, System.Net.Sockets.Socket client, System.Object state) [0x00000]    <filename unknown>:0
  at SuperSocket.SocketEngine.SocketListenerBase.OnNewClientAccepted (System.Net  ockets.Socket socket, System.Object state) [0x00000] in <filename unknown>:0
  at SuperSocket.SocketEngine.TcpAsyncSocketListener.ProcessAccept (System.Net.S  kets.SocketAsyncEventArgs e) [0x00000] in <filename unknown>:0
  at SuperSocket.SocketEngine.TcpAsyncSocketListener.acceptEventArg_Completed (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) [0x00000] in <fi  name unknown>:0
  at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.Soc  tAsyncEventArgs e) [0x00000] in <filename unknown>:0
  at System.Net.Sockets.SocketAsyncEventArgs.AcceptCallback (IAsyncResult ares)   x00000] in <filename unknown>:0
  at System.Net.Sockets.SocketAsyncEventArgs.DispatcherCB (IAsyncResult ares) [0x00000] in <filename unknown>:0

发送超时

服务器用SuperSocket,客户端使用Cocos在手机上使用wifi连接发送数据,会出现如下错误:
2015-01-14 13:25:14,179 [5896] ERROR WSGatewaySvr - Session: 8c62d585-349b-4e1a-ac06-0544ecca2421/123.123.123.123:50022
Unexpected socket error: 10060
System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

看了代码,貌似是timeout了.
不过我服务器只有一个连接发送数据也会出现这种情况.
这跟wifi环境有很大关系?
麻烦能提供查问题或解决的办法,源代码看了,不知从何下手.

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.