• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by STBarnard · Nov 13, 2015 at 01:42 PM · unity 5networkingchannels

UNET Setting up a new channel and subsequently message fragmentation

Hello, Trying to send a large byte array from Client to Server and was immediately told it was too large and that the channel (I was using channel 0) does not support message segmentation. So I was looking into adding a new channel of type "Reliable Fragmented".

So, I started by simply adding a channel to the default config like this:

 int Channel;
 NetworkClient NetClient = new NetworkClient ();
 Channel = NetworkClient.hostTopology.DefaultConfig.AddChannel (QosType.ReliableFragmented);
 NetClient.SendByChannel (100, NetMsg, Channel);

When I attempted to Send like this I received the following errors:

 channelid < connection -> config -> MaxChannels ();

 Invalid channelID (2) for connection (1)

At that point I figured maybe it is not working because I am setting this channel up after connecting? So I did this:

 int Channel;
 NetworkClient NetClient = new NetworkClient ();
 ConnectionConfig Config = new ConnectionConfig ()
 Config.addChannel (QosType.Reliable);
 Config.addChannel (QosType.Unreliable);
 Channel = Config.AddChannel (Qos.RelaibleFragmented);
 HostTopology Toplogy = new HostTopology  (Config, 10000);
 NetClient.Configure (Topology);
 NetClient.Connect (serverIP, serverPort);
 NetClient.SendByChannel  (100, NetMsg, Channel);

Error:

 CRCmismatch

Any advice? What are the best practices steps in order to set up a custom channel that allows for message fragmentation?

Thanks, Sean

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image STBarnard · Nov 16, 2015 at 03:36 PM 0
Share

I added a new channel to both the client and the server using:

Client:

 NetworkClient NetClient = new NetworkClient ();
 NetClient.hostTopology.DefaultConfig.AddChannel (QosType.ReliableFragmented);

Server:

 NetworkServer.hostTopology.DefaultConfig.AddChannel (QosType.ReliableFragmented);

I no longer get the CRC$$anonymous$$ismatch error but I do get the following:

 channelId < connection ->config->$$anonymous$$axChannels()
 
 Wrong channelId {2} for connectionId {1}

On the Client side.

Nothing makes it Server Side.

I know people have done this successfully, if they could give me an example of what they did to set this up I would appreciate it greatly.

Thanks, Sean

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by seanr · Nov 13, 2015 at 06:26 PM

the client and server must have the same channel configurations. that is what causes CRC error.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image STBarnard · Nov 13, 2015 at 08:40 PM 0
Share

I tried the same code on both sides, still got CRC error. Is there something I am missing perhaps?

avatar image seanr · Nov 16, 2015 at 04:01 PM 1
Share

You must call Configure() on client and server

avatar image
1

Answer by STBarnard · Nov 16, 2015 at 04:36 PM

I got it,

Here it is:

Server:

 ConnectionConfig Config = new ConnectionConfig ();
 Config.AddChannel (QosType.Reliable);
 Config.AddChannel (QosType.Unreliable);
 Config.AddChannel (QosType.ReliableFragmented);
 HostTopology Topology = new HostTopology (Config, MaxConnections);
 NetworkServer.Configure (Topology);
 NetworkServer.Connect (Port);

Client:

 NetworkClient NetClient = new NetworkClient ();
 ConnectionConfig Config = new ConnectionConfig ();
 Config.AddChannel (QosType.Reliable);
 Config.AddChannel (QosType.Unreliable);
 Config.AddChannel (QosType.ReliableFragmented);
 HostTopology Topology = new HostTopology (Config, MaxConnections);
 NetClient.Configure (Topology);
 NetClient.Connect (ServerIP, ServerPort);

Regards, Sean

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sathish89 · Sep 07, 2016 at 09:10 PM 0
Share

Hi Sean, Thanks much. This is very much helpful as i searched most of the post and was not able to succeed in sending image over network. Finally, landed up here and it was a piece of cake :-)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

UNET Matchmaking Filter Issues 1 Answer

Unity 5.2 SyncVar hook only gets called on host. VS debugger dosent debug it fully. 0 Answers

Unity uNet Connection Problems 0 Answers

Stun and turn server possible with Unity Netowking? 0 Answers

NetworkServer.Destroy(GameObject) disables Client objects instead of destroying them 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges